Skip to content

Commit

Permalink
feat(log): add timing log level
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 12, 2024
1 parent 978fbf9 commit 12f35fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const { log } = require('proc-log')
for debugging.
* `log.http(...args)` calls `process.emit('log', 'http', ...args)`
Information about HTTP requests made and/or completed.
* `log.timing(...args)` calls `process.emit('log', 'timing', ...args)`
Timing information.
* `log.pause()` calls `process.emit('log', 'pause')` Used to tell
the consumer to stop printing messages.
* `log.resume()` calls `process.emit('log', 'resume')`
Expand All @@ -39,7 +41,7 @@ const { log } = require('proc-log')

## Examples

Every method calls `process.emit('log', level, ...otherArgs)` internally.
Every `log` method calls `process.emit('log', level, ...otherArgs)` internally.
So in order to consume those events you need to do `process.on('log', fn)`.

### Colorize based on level
Expand Down
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'verbose',
'http',
'silly',
'timing',
'pause',
'resume',
],
Expand All @@ -18,6 +19,7 @@ module.exports = {
verbose: (...args) => process.emit('log', 'verbose', ...args),
http: (...args) => process.emit('log', 'http', ...args),
silly: (...args) => process.emit('log', 'silly', ...args),
timing: (...args) => process.emit('log', 'timing', ...args),
pause: (...args) => process.emit('log', 'pause', ...args),
resume: (...args) => process.emit('log', 'resume', ...args),
},
Expand Down
1 change: 1 addition & 0 deletions tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Array [
"verbose",
"http",
"silly",
"timing",
"pause",
"resume",
]
Expand Down

0 comments on commit 12f35fe

Please sign in to comment.