Mongo Shell-控制台/调试日志 [英] Mongo Shell - Console/Debug Log

查看:160
本文介绍了Mongo Shell-控制台/调试日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个愚蠢的问题.试用Mongo Shell.

Probably a dumb question. Experimenting with Mongo shell.

我想做类似的事情:

matt@linuxvm:~/mongodb-linux-i686-1.2.3/bin$ ./mongo
MongoDB shell version: 1.2.3
url: test
connecting to: test
Thu Feb 25 20:57:47 connection accepted from 127.0.0.1:37987 #3
type "help" for help
> function test() { debug.log("hello") }
> test()
Thu Feb 25 20:58:06 JS Error: ReferenceError: debug is not defined (shell):0

换句话说,当从Mongo shell中评估JS函数时,如何输出到控制台.我打算提供一些管理员/填充脚本,以输出一些详细信息.

In other words, how can I output to the console when evaluating JS functions from within Mongo shell. I intend some admin / populate script that I'd like to output some nicety info.

我已经尝试过console.log,debug.log,记录明显的..

I've tried console.log, debug.log, log the obvious ones..

推荐答案

我找到了答案,就是print

print("sweetnesss");

这篇关于Mongo Shell-控制台/调试日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆