Commit a0aeacdd authored by mercury233's avatar mercury233

make the auth module use bunyan

parent bba72cea
......@@ -45,13 +45,16 @@ moment.updateLocale('zh-cn', {
}
})
bunyan = require 'bunyan'
log = bunyan.createLogger name: "auth"
if not fs.existsSync('./logs')
fs.mkdirSync('./logs')
add_log = (message) ->
mt = moment()
log.info(message)
text = mt.format('YYYY-MM-DD HH:mm:ss') + " --> " + message + "\n"
console.log(text)
res = false
try
fs.appendFileSync("./logs/"+mt.format('YYYY-MM-DD')+".log", text)
......
......@@ -28,7 +28,7 @@ or as follows, to use a specific set of permissions.
*/
(function() {
var add_log, check_permission, default_data, fs, loadJSON, moment, reload, save, setting_save, users;
var add_log, bunyan, check_permission, default_data, fs, loadJSON, log, moment, reload, save, setting_save, users;
fs = require('fs');
......@@ -54,6 +54,12 @@ or as follows, to use a specific set of permissions.
}
});
bunyan = require('bunyan');
log = bunyan.createLogger({
name: "auth"
});
if (!fs.existsSync('./logs')) {
fs.mkdirSync('./logs');
}
......@@ -61,8 +67,8 @@ or as follows, to use a specific set of permissions.
add_log = function(message) {
var mt, res, text;
mt = moment();
log.info(message);
text = mt.format('YYYY-MM-DD HH:mm:ss') + " --> " + message + "\n";
console.log(text);
res = false;
try {
fs.appendFileSync("./logs/" + mt.format('YYYY-MM-DD') + ".log", text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment