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

Add an option to reflect passed log to console (turned off by default) #5

Open
Arech opened this issue May 11, 2011 · 2 comments
Open

Comments

@Arech
Copy link

Arech commented May 11, 2011

That would ease debugging when it is convenient to log data into stream and to console at the same time.

change log.js:23 var Log = exports = module.exports = function Log(level, stream, bReflectToConsole){
then add a following line after assigning of this.stream : this.reflect2console = (this.stream === process.stdout ? false : !!bReflectToConsole);

refactor log function in log.js:146 to

log: function(levelStr, msg) {
    if (exports[levelStr] <= this.level) {
        var s = '[' + new Date().toUTCString() + ']'
            + ' ' + levelStr
            + ' ' + msg;
        this.stream.write(s+ '\n');
        if (this.reflect2console) console.log(s);
    }
  },
@tj
Copy link
Owner

tj commented May 11, 2011

why not have stream: process.stdout in development?

@Arech
Copy link
Author

Arech commented May 11, 2011

Because you will lose all stdout as soon as you close terminal, but you won't lose a log file. Console logging is only supplemental feature for file logging, for use "with", not "instead".

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