Skip to content
Show some ❤️ to Node.js process errors
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
docs
gulp
src
test
.all-contributorsrc
.editorconfig
.eslintrc.js
.gitignore
.prettierrc.js
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md Add translations Mar 15, 2019
CONTRIBUTING.md Fix code blocks Mar 18, 2019
LICENSE
README.md
ava.config.js
gulpfile.js
package-lock.json
package.json
register.js

README.md

Codecov Travis Node Gitter

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.

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.

Usage

There are two ways to load this library. The first is to use the node -r CLI flag:

node -r log-process-errors/register ...

The second is:

const logProcessErrors = require('log-process-errors')
logProcessErrors(options)

logProcessErrors() should be called as early as possible in the code.

Options

options is an optional object with the following properties.

This is a quick summary. Please see the options full documentation for more information and examples.

log

Type: function(message, level, event)

Customize how events are logged.

level

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

Which log level to use.

message

Type: function(level, event, options) => string

Customize messages.

colors

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

Colorize messages.

exitOn

Type: string[]
Default: ["uncaughtException"]

Which events should trigger process.exit(1).

Support

If you found a bug or would like a new feature, don't hesitate to submit an issue on GitHub.

For other questions, feel free to chat with us on Gitter.

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 submit a correction.

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

Code of conduct

This project welcomes anyone regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.

Contributors

ehmicky
ehmicky

💻 🎨 🤔 📖
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.