npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node_log_json_on_fatal

v0.9.2

Published

Output a JSON object when there is a fatal error for log watchers to catch

Downloads

17

Readme

node_log_json_on_fatal

Node module that will log a JSON object to stderr if the process is crashing with a fatal error.

Prebuilt binaries are hosted in the Github release to simplify use. An alpine compatible version is included.

The package is setup with node-pre-gyp so if the needed binary exists in the Github releases, it will downloaded. But if does not exist, it will be compiled locally.

Why?

The default behavior for Node.js when encountering a fatal error is to print useful info to standard error and crash. But this data is unstructured, so if you are using a log monitoring service that expects JSON objects, it is not very helpful. This corrects that to get the basic data into JSON form so that it can be processed by log monitoring services.

Usage

npm install node_log_json_on_fatal

The module exports one function with the signature:

function setup(template, msgPath='message', locPath='location')

It can be used like:

const fatal = require('node_log_json_on_fatal');

const template = {
    whatever: 'fields that need to be logged',
    canBe: {
        nested: true,
        lists: [true, true],
    },
    details: {},
};

fatal.setup(template, 'details.message', 'details.location');

If the process crashes with a Node.js fatal error, the V8 supplied message and location with be added to the template object at the specified paths and the object will be logged as JSON.

NOTE: The module deep clones the template, meaning later changes to it will not be reflected in the output.

Thanks

Development

This uses node-gyp for building, so you'll need the normal C++ build tools like make and a compiler.

A basic build and test cycle can use invoked with:

npm run test

Deployment

In this repo, Github actions are setup to build the binaries for the common operating systems when a Github release is created. So, the process for releasing a version is:

  1. git fetch
  2. git status
  3. vi CHANGELOG.md
  4. git add CHANGELOG.md
  5. npm version -f -m "Release new version" <new-version>
  6. git push && git push --tags
  7. Create a release on github to build binaries
  8. npm publish