-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: force red color on errors, yellow on warnings. #860
Conversation
c291e68
to
0e85f11
Compare
static loggerfn(title) { | ||
let log = loggersByTitle[title]; | ||
if (!log) { | ||
log = loggersByTitle[title] = debug(title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two lines for rock solid clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const EventEmitter = require('events').EventEmitter; | ||
|
||
debugNode.colors = [6, 2, 4, 5]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment for what these does. I'm a noob.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
log = loggersByTitle[title] = debug(title); | ||
// errors with red, warnings with yellow. | ||
// eslint-disable-next-line no-nested-ternary | ||
log.color = title.includes('error') ? 1 : title.includes('warn') ? 3 : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1/3 could be enums
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (!loggersByTitle[title]) { | ||
loggersByTitle[title] = debug(title); | ||
const log = Log.loggerfn(title); | ||
return log(...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do these return, incidentally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined. i'll nuke the explicit return
loggersByTitle[title] = log; | ||
// errors with red, warnings with yellow. | ||
// eslint-disable-next-line no-nested-ternary | ||
log.color = title.endsWith('error') ? colors.red : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit extract this lookup logic into a named fn.
nit extract error and warn string into named module private consts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit extract error and warn string into named module private consts
disagree (maybe if we were exposing Log.ERROR
but we have log.error()
for that), but that shouldn't be a surprise by this point :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Small followup from #835, from @wardpeet's suggestion..
Errors are red, warnings are yellow. And the other logs will never use those colors