Gathering detailed insights and metrics for proc-log
Gathering detailed insights and metrics for proc-log
Gathering detailed insights and metrics for proc-log
Gathering detailed insights and metrics for proc-log
npm install proc-log
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
11 Stars
96 Commits
3 Forks
7 Watchers
1 Branches
71 Contributors
Updated on Jul 09, 2025
Latest Version
5.0.0
Package Id
proc-log@5.0.0
Unpacked Size
12.00 kB
Size
3.90 kB
File Count
4
NPM Version
10.8.3
Node Version
22.8.0
Published on
Sep 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Emits events on the process object which a listener can consume and print to the terminal or log file.
This is used by various modules within the npm CLI stack in order to send log events that can be consumed by a listener on the process object.
Currently emits log
, output
, input
, and time
events.
1const { log, output, input, time } = require('proc-log')
output.standard(...args)
calls process.emit('output', 'standard', ...args)
This is for general standard output. Consumers will typically show this on stdout (after optionally formatting or filtering it).
output.error(...args)
calls process.emit('output', 'error', ...args)
This is for general error output. Consumers will typically show this on stderr (after optionally formatting or filtering it).
output.buffer(...args)
calls process.emit('output', 'buffer', ...args)
This is for buffered output. Consumers will typically buffer this until they are ready to display.
output.flush(...args)
calls process.emit('output', 'flush', ...args)
This is to indicate that the output buffer should be flushed.
output.LEVELS
an array of strings of all output method names
log.error(...args)
calls process.emit('log', 'error', ...args)
The highest log level. For printing extremely serious errors that indicate something went wrong.
log.warn(...args)
calls process.emit('log', 'warn', ...args)
A fairly high log level. Things that the user needs to be aware of, but which won't necessarily cause improper functioning of the system.
log.notice(...args)
calls process.emit('log', 'notice', ...args)
Notices which are important, but not necessarily dangerous or a cause for excess concern.
log.info(...args)
calls process.emit('log', 'info', ...args)
Informative messages that may benefit the user, but aren't particularly important.
log.verbose(...args)
calls process.emit('log', 'verbose', ...args)
Noisy output that is more detail that most users will care about.
log.silly(...args)
calls process.emit('log', 'silly', ...args)
Extremely noisy excessive logging messages that are typically only useful 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')
Used to tell the consumer that it is ok to print messages again.
log.LEVELS
an array of strings of all log method names
input.start(fn?)
calls process.emit('input', 'start')
Used to tell the consumer that the terminal is going to begin reading user input. Returns a function that will call input.end()
for convenience.
This also takes an optional callback which will run input.end()
on its completion. If the callback returns a Promise
then input.end()
will be run during finally()
.
input.end()
calls process.emit('input', 'end')
Used to tell the consumer that the terminal has stopped reading user input.
input.read(...args): Promise
calls process.emit('input', 'read', resolve, reject, ...args)
Used to tell the consumer that the terminal is reading user input and returns a Promise
that the producer can await
until the consumer has finished its async action.
This emits resolve
and reject
functions (in addition to all passed in arguments) which the consumer must use to resolve the returned Promise
.
time.start(timerName, fn?)
calls process.emit('time', 'start', 'timerName')
Used to start a timer with the specified name. Returns a function that will call time.end()
for convenience.
This also takes an optional callback which will run time.end()
on its completion. If the callback returns a Promise
then time.end()
will be run during finally()
.
time.end(timerName)
calls process.emit('time', 'end', timeName)
Used to tell the consumer to stop a timer with the specified name.
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)
.
Here's an example of how to consume proc-log
log events and colorize them based on level:
1const chalk = require('chalk') 2 3process.on('log', (level, ...args) => { 4 if (level === 'error') { 5 console.log(chalk.red(level), ...args) 6 } else { 7 console.log(chalk.blue(level), ...args) 8 } 9})
log.pause
and log.resume
are included so you have the ability to tell your consumer that you want to pause or resume your display of logs. In the npm CLI we use this to buffer all logs on init until we know the correct loglevel to display. But we also setup a second handler that writes everything to a file even if paused.
1let paused = true 2const buffer = [] 3 4// this handler will buffer and replay logs only after `procLog.resume()` is called 5process.on('log', (level, ...args) => { 6 if (level === 'resume') { 7 buffer.forEach((item) => console.log(...item)) 8 paused = false 9 return 10 } 11 12 if (paused) { 13 buffer.push([level, ...args]) 14 } else { 15 console.log(level, ...args) 16 } 17}) 18 19// this handler will write everything to a file 20process.on('log', (...args) => { 21 fs.appendFileSync('debug.log', args.join(' ')) 22})
start
and end
producer.js
1const { output, input } = require('proc-log') 2const { readFromUserInput } = require('./my-read') 3 4// Using callback passed to `start` 5try { 6 const res = await input.start( 7 readFromUserInput({ prompt: 'OK?', default: 'y' }) 8 ) 9 output.standard(`User said ${res}`) 10} catch (err) { 11 output.error(`User cancelled: ${err}`) 12} 13 14// Manually calling `start` and `end` 15try { 16 input.start() 17 const res = await readFromUserInput({ prompt: 'OK?', default: 'y' }) 18 output.standard(`User said ${res}`) 19} catch (err) { 20 output.error(`User cancelled: ${err}`) 21} finally { 22 input.end() 23}
consumer.js
1const { read } = require('read') 2 3process.on('input', (level) => { 4 if (level === 'start') { 5 // Hide UI to make room for user input being read 6 } else if (level === 'end') { 7 // Restore UI now that reading is ended 8 } 9})
read
to call read()
producer.js
1const { output, input } = require('proc-log') 2 3try { 4 const res = await input.read({ prompt: 'OK?', default: 'y' }) 5 output.standard(`User said ${res}`) 6} catch (err) { 7 output.error(`User cancelled: ${err}`) 8}
consumer.js
1const { read } = require('read') 2 3process.on('input', (level, ...args) => { 4 if (level === 'read') { 5 const [res, rej, opts] = args 6 read(opts).then(res).catch(rej) 7 } 8})
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
all changesets reviewed
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More