如何格式化Mongoose调试输出-漂亮的打印 [英] How to format Mongoose debug output - pretty print
本文介绍了如何格式化Mongoose调试输出-漂亮的打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使Mongoose调试输出在控制台中看起来很漂亮?当前输出显示在一行上.
How can I make Mongoose debug output look pretty in console? Currently the output is displayed on one line.
推荐答案
这是我整理的内容,也许有人会觉得有用.
Here is something I put together, maybe somebody will find it useful.
为node.js安装颜色模块(这是可选的):
npm install colors
Install colors module for node.js (this is optional):
npm install colors
然后在您的文件中:
var colors = require('colors');
mongoose.set('debug', function (collectionName, method, query, doc) {
console.log(
'Mongoose: '.cyan +
collectionName +
'.' +
method +
' (' +
JSON.stringify(query, null, 2) + ')');
});
这篇关于如何格式化Mongoose调试输出-漂亮的打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文