-
Notifications
You must be signed in to change notification settings - Fork 15
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
Bind the custom logger to the log methods, useful for loggers that use "this" on their own log methods #25
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,14 +65,14 @@ module.exports = function CaptainsLog(overrides) { | |
// If no reasonable alternative is possible, don't log | ||
var nullLog = function() {}; | ||
|
||
logger.debug = logger.debug || nullLog; | ||
logger.info = logger.info || nullLog; | ||
logger.warn = logger.warn || logger.error || nullLog; | ||
logger.error = logger.error || nullLog; | ||
logger.crit = logger.crit || logger.error || nullLog; | ||
logger.verbose = logger.verbose || nullLog; | ||
logger.silly = logger.silly || nullLog; | ||
logger.blank = logger.blank || nullLog; | ||
logger.debug = logger.debug ? logger.debug.bind(logger) : nullLog; | ||
logger.info = logger.info ? logger.info.bind(logger) : nullLog; | ||
logger.error = logger.error ? logger.error.bind(logger) : nullLog; | ||
logger.warn = logger.warn ? logger.warn.bind(logger) : logger.error; | ||
logger.crit = logger.crit ? logger.crit.bind(logger) : logger.error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here- kept the "error" fallback but lost the nullLog short-circuit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, I think we're losing the bind in our fallback -- maybe it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikermcneil I see what you say, I've added the bindings |
||
logger.verbose = logger.verbose ? logger.verbose.bind(logger) : nullLog; | ||
logger.silly = logger.silly ? logger.silly.bind(logger) : nullLog; | ||
logger.blank = logger.blank ? logger.blank.bind(logger) : nullLog; | ||
} | ||
|
||
// Make logger callable and stuff (wrap it) | ||
|
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.
looks like we kept the "error" fallback, but lost the nullLog short-circuit here
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.
Also missing a
.bind
right? so likelogger.warn? logger.warn.bind(logger) : logger.error? logger.error.bind(logger) : nullLog
?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.
In the
warn
method? well at the timewarn
is being set,error
should be whether theerror
function if it exists, or thenullLog
assigned in theerror
shortcut, am I correct?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.
@mikermcneil In case you didn't see my comments up there
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.
@mikermcneil I see what you say, I've added the bindings