You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I read the code in Logger.js and it seems that the level set in transports has higher priority than the level set in logger. I am a little confused why it is designed or implemented this way. In most cases, I think the transports will be shared across all loggers which are used for different components of an application. If I set one file transport to only debug logs and another one to record other logs, then I cannot set different log policies for different loggers. For example, if I want to see debug logs for only one logger/component so that logs from other logger/component will not bother me during my investigation. Wouldn't it be more sensible if the code in log function of Logger.js be like this:
function emit(name, next) {
var transport = self.transports[name];
if (!transport.level || self.levels[transport.level] <= self.levels[level]) {
// || (!transport.level && self.levels[self.level] <= self.levels[level])) { //comment out //logger level condition
transport.log(level, msg, meta, function (err) {
if (err) {
err.transport = transport;
cb(err);
return next();
}
self.emit('logging', transport, level, msg, meta);
next();
});
} else {
next();
}
}
...........
// use logger level to controll which kind of log to record for the current logger
if (self.levels[self.level] <= self.levels[level]) {
async.forEach(this._names, emit, cb);
}
The text was updated successfully, but these errors were encountered:
pose
changed the title
log level controll question
log level control question
Dec 16, 2014
Hello,
I read the code in Logger.js and it seems that the level set in transports has higher priority than the level set in logger. I am a little confused why it is designed or implemented this way. In most cases, I think the transports will be shared across all loggers which are used for different components of an application. If I set one file transport to only debug logs and another one to record other logs, then I cannot set different log policies for different loggers. For example, if I want to see debug logs for only one logger/component so that logs from other logger/component will not bother me during my investigation. Wouldn't it be more sensible if the code in log function of Logger.js be like this:
function emit(name, next) {
var transport = self.transports[name];
if (!transport.level || self.levels[transport.level] <= self.levels[level]) {
// || (!transport.level && self.levels[self.level] <= self.levels[level])) { //comment out //logger level condition
transport.log(level, msg, meta, function (err) {
if (err) {
err.transport = transport;
cb(err);
return next();
}
self.emit('logging', transport, level, msg, meta);
next();
});
} else {
next();
}
}
...........
// use logger level to controll which kind of log to record for the current logger
if (self.levels[self.level] <= self.levels[level]) {
async.forEach(this._names, emit, cb);
}
The text was updated successfully, but these errors were encountered: