如何格式化Mongoose调试输出

编程入门 行业动态 更新时间:2024-10-23 19:29:59
本文介绍了如何格式化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调试输出

本文发布于:2023-11-16 17:05:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Mongoose

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!