我希望重载sails.log函数,如info、debug、error等,以包含文件名的路径,这些路径来自正在打印日志的位置。例如,
// api/controllers/UserController.js
module.exports = {
create: function (req, res) {
// some operations
sails.log.info("created a new user");
}
}
上面的log语句应该打印
[api/controllers/UserController.js] info: created a
我有一个日志文件,在这里我打印请求和响应XML主体。这个日志文件还有一些不是XML的附加行。以下例子
===========================================
<request>
<data>
abc
</data>
</request>
some random lines concerning the processing of request..
fha;js;fkgak;gj;kj;a
jgahkg;gaj;
Now response follows
<response>
<
bank_data集合中有6条记录。因此,我希望输出结果只显示6,但6与时间戳和其他文本日志一起打印。
script.js有以下代码
use test;
db.bank_data.find({first_name : "logan"}).count();
在命令行中运行上述文件
mongo --quiet script.js > result.txt
输出 result.txt文件有以下输出
2015-05-27T17:12:09.752+0530 I CONTROL Hotfix KB2731284 or later update is installed, no n