Need help with log-process-errors?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

ehmicky
445 Stars 9 Forks Apache License 2.0 2.1K Commits 0 Opened issues

Description

Show some ❤️ to Node.js process errors

Services available

!
?

Need anything else?

Contributors list

# 11,752
netlify
unix
npx
exec
2031 commits
# 8,236
reasonm...
Svelte
fish-sh...
cypress
6 commits
# 19,802
tshark
JavaScr...
TypeScr...
React
4 commits

Codecov Build Node Twitter Medium

📰 Medium article.

Show some ❤️ to Node.js process errors.

Node.js prints process errors (

uncaughtException
,
warning
,
unhandledRejection
,
rejectionHandled
) on the console which is very useful. Unfortunately those errors:

log-process-errors
fixes all those issues.

Without

log-process-errors
:

Screenshot before

With

log-process-errors
:

Screenshot after

Use cases

  • Proper logging of process errors in production.
  • Debugging of process errors in development.
  • Automated testing of process errors.

Demo

You can try this library:

Install

Production code (e.g. a server) can install this either as a production or development dependency:

npm install log-process-errors

However, libraries should install this as a development dependency:

npm install -D log-process-errors

This is because logging is modified globally and libraries users might not expect this side-effect. Also, this might lead to conflicts between libraries.

This package is an ES module and must be loaded using an

import
or
import()
statement
, not

require()
.

Usage

import logProcessErrors from 'log-process-errors'
logProcessErrors(options)

logProcessErrors()
should be called as early as possible in the code, before other
import
statements.

Options

options
is an optional object with the following properties.

log

Type:

function(error, level, originalError)

Customizes how process errors are logged.\ Full documentation.

level

Type:

object
\ Default:
{ warning: 'warn', multipleResolves: 'info', default: 'error' }

Which log level to use.\ Full documentation.

exitOn

Type:

string[]
\ Default:
['uncaughtException', 'unhandledRejection']
for Node
>= 15.0.0
,
['uncaughtException']
otherwise.

Which process errors should trigger

process.exit(1)
.\ Full documentation.

testing

Type:

string
\ Value:
'ava'
,
'mocha'
,
'jasmine'
,
'tape'
or
'node_tap'
\ Default:
undefined

When running tests, makes them fail if there are any process errors.\ Full documentation.

colors

Type:

boolean
\ Default:
true
if the output is a terminal.

Colorizes messages.\ Full documentation.

Support

For any question, don't hesitate to submit an issue on GitHub.

Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.

Contributing

This project was made with ❤️. The simplest way to give back is by starring and sharing it online.

If the documentation is unclear or has a typo, please click on the page's

Edit
button (pencil icon) and suggest a correction.

If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!

Thanks go to our wonderful contributors:


ehmicky

💻 🎨 🤔 📖

Steven Vachon

💬

Hongarc

📖 💻

Andy Brenneke

🐛

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.