我想在使用 mongoose 的数据访问层中记录错误。
如何使单元测试变得容易?将猫鼬(数据访问+中间件)与温斯顿(记录器)集成的最佳方法是什么。
谢谢,
帕维尔
我想在使用 mongoose 的数据访问层中记录错误。
如何使单元测试变得容易?将猫鼬(数据访问+中间件)与温斯顿(记录器)集成的最佳方法是什么。
谢谢,
帕维尔
这是我如何mongoose
与winston
.
// Create the mongoose instance
var mongoose = require('mongoose');
mongoose.connect(...); // etc.
// Create the winston logger
var winston = require('winston')
, logger = new (winston.Logger)({
transports: new (winston.transports.Console)({
uncaughtException: true,
level: 'debug',
colorize: 'true'
}),
});
// Configure mongoose for debug
mongoose.set('debug', function (collectionName, method, query, doc, options) {
logger.info('mongo collection: %s method: %s', collectionName, method);
});