-
Notifications
You must be signed in to change notification settings - Fork 865
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
Added enable option and support the level 'disable' #53
Changes from 3 commits
a39c115
3b71d67
e5e64ad
df662a6
c0b7d04
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 |
---|---|---|
|
@@ -19,11 +19,24 @@ var levels = { | |
debug: 20, | ||
trace: 10 | ||
} | ||
|
||
// private property | ||
Object.defineProperty(levels, 'silent', { | ||
value: 100, | ||
enumerable: false | ||
}) | ||
|
||
var nums = Object.keys(levels).reduce(function (o, k) { | ||
o[levels[k]] = k | ||
return o | ||
}, {}) | ||
|
||
// private property | ||
Object.defineProperty(nums, '100', { | ||
value: 'silent', | ||
enumerable: false | ||
}) | ||
|
||
function pino (opts, stream) { | ||
if (opts && opts._writableState) { | ||
stream = opts | ||
|
@@ -44,6 +57,10 @@ function pino (opts, stream) { | |
buf: '' | ||
} | ||
|
||
if (opts.enable === false) { | ||
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. ....maybe.. opts.silent ? so then also - should there 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. I tend to prefer positive logic, I find this easier to reason about but harder to work with in code. Basically 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. ok sure but.. 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. updated 👍 |
||
level = 'silent' | ||
} | ||
|
||
var logger = new Pino(level, stream, serializers, stringify, end, name, hostname, slowtime, '', cache, formatOpts) | ||
if (cache) { | ||
onExit(function (code, evt) { | ||
|
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.
enumerable: false is default, doesn't need to be set
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.
I know, I've left it there for increased readability.