mirror of https://github.com/xwiki-labs/cryptpad
unify format of console output with stored logs
This commit is contained in:
parent
8a5d012edf
commit
37d3995ac1
32
lib/log.js
32
lib/log.js
|
@ -23,29 +23,13 @@ var write = function (ctx, content) {
|
|||
// various degrees of logging
|
||||
const logLevels = Logger.levels = ['silly', 'verbose', 'debug', 'feedback', 'info', 'warn', 'error'];
|
||||
|
||||
var handlers = {
|
||||
silly: function (ctx, time, tag, info) {
|
||||
console.log('[SILLY]', time, tag, info);
|
||||
},
|
||||
debug: function (ctx, time, tag, info) {
|
||||
console.log('[DEBUG]', time, tag, info);
|
||||
},
|
||||
verbose: function (ctx, time, tag, info) {
|
||||
console.log('[VERBOSE]', time, tag, info);
|
||||
},
|
||||
feedback: function (ctx, time, tag, info) {
|
||||
console.log('[FEEDBACK]', time, tag, info);
|
||||
},
|
||||
info: function (ctx, time, tag, info) {
|
||||
console.info('[INFO]', time, tag, info);
|
||||
},
|
||||
warn: function (ctx, time, tag, info) {
|
||||
console.warn('[WARN]', time, tag, info);
|
||||
},
|
||||
error: function (ctx, time, tag, info) {
|
||||
console.error('[ERROR]', time, tag, info);
|
||||
}
|
||||
};
|
||||
var handlers = {};
|
||||
['silly', 'debug', 'verbose', 'feedback', 'info'].forEach(function (level) {
|
||||
handlers[level] = function (ctx, content) { console.log(content); };
|
||||
});
|
||||
['warn', 'error'].forEach(function (level) {
|
||||
handlers[level] = function (ctx, content) { console.error(content); }
|
||||
});
|
||||
|
||||
var noop = function () {};
|
||||
|
||||
|
@ -65,7 +49,7 @@ var createLogType = function (ctx, type) {
|
|||
return;
|
||||
}
|
||||
if (ctx.logToStdout && typeof(handlers[type]) === 'function') {
|
||||
handlers[type](ctx, time, tag, info);
|
||||
handlers[type](ctx, content);
|
||||
}
|
||||
write(ctx, content);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue