Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log level control question #416

Closed
zpdpnn opened this issue Jul 8, 2014 · 1 comment
Closed

log level control question #416

zpdpnn opened this issue Jul 8, 2014 · 1 comment

Comments

@zpdpnn
Copy link

zpdpnn commented Jul 8, 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);
}

@pose pose changed the title log level controll question log level control question Dec 16, 2014
@indexzero
Copy link
Member

Duplicate of (and fixed by #290).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants