-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(refactor): don't loop through levels to generate log export
Instead use a test to make sure LEVELS an functions match
- Loading branch information
Showing
3 changed files
with
49 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
const log = { | ||
LEVELS: [ | ||
'notice', | ||
'error', | ||
'warn', | ||
'info', | ||
'verbose', | ||
'http', | ||
'silly', | ||
'pause', | ||
'resume', | ||
], | ||
module.exports = { | ||
log: { | ||
LEVELS: [ | ||
'notice', | ||
'error', | ||
'warn', | ||
'info', | ||
'verbose', | ||
'http', | ||
'silly', | ||
'pause', | ||
'resume', | ||
], | ||
error: (...args) => process.emit('log', 'error', ...args), | ||
notice: (...args) => process.emit('log', 'notice', ...args), | ||
warn: (...args) => process.emit('log', 'warn', ...args), | ||
info: (...args) => process.emit('log', 'info', ...args), | ||
verbose: (...args) => process.emit('log', 'verbose', ...args), | ||
http: (...args) => process.emit('log', 'http', ...args), | ||
silly: (...args) => process.emit('log', 'silly', ...args), | ||
pause: (...args) => process.emit('log', 'pause', ...args), | ||
resume: (...args) => process.emit('log', 'resume', ...args), | ||
}, | ||
} | ||
for (const level of log.LEVELS) { | ||
log[level] = (...args) => process.emit('log', level, ...args) | ||
} | ||
|
||
module.exports = { log } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters