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

@neo9/n9-node-log

v5.0.0

Published

Logging node module managing json or human format

Downloads

2,611

Readme

n9-node-log

Logging node module based on Pino.

npm version Travis Coverage license

Requirements

  • NodeJS >= 10.0.0

Installation

npm install --save @neo9/n9-node-log

Usage

import n9Log from '@neo9/n9-node-log';

const log = n9Log('my-app-name');

// Write on stdout
log.trace('This is a trace message');
log.debug('This is a debug message');
log.info('This is an information message');
log.warn('Warning, this feature will be removed soon');
// Write on stderr
log.error('An error appened');
2017-05-12T15:57:14.474Z - info: [my-app-name] This is an information message
2017-05-12T15:57:14.689Z - warn: [my-app-name] Warning, this feature will be removed soon
2017-05-12T15:57:14.974Z - error: [my-app-name] An error appened

Metadata

log.info('Log with metadata', { anything: 'this is metadata' });
log.error('Here an error', new Error('hello'));
2017-05-12T15:57:14.474Z - info: [my-app-name] Log with metadata anything=this is metadata
2017-05-12T15:57:14.785Z - error: [node-ts-skeleton] Here an error Error: hello
     err: {
      "type": "Error",
      "message": "something-went-wrong",
      "stack":
          Error: something-went-wrong
              at /home/bdaniel/projects/neo9/n9-libs/n9-node-log/test/index.ts:110:29
    }

Prefixing

const logUsers = log.module('users');

logUsers.info('Log specific to users module');
2017-05-12T15:57:14.474Z - info: [my-app-name:users] Log specific to users module

Profiling

log.profile('test');
setTimeout(() => log.profile('test'), 1000);
2017-05-12T15:57:14.474Z - info: [my-app-name] test {"durationMs":1000}

Log level

You can filter the list of logs on startup with the N9LOG environment or with the level option.

Possible values:

  • trace: Display all logs
  • debug: Display debug + info + warn + error logs
  • info: Display info + warn + error logs
  • warn: Display warn + error logs
  • error: Display only error logs

Default value: info

Example: N9LOG=error node server.js will display only error logs.

For performance matter, you can check if you need to compute your log data :

if (log.isLevelEnabled('debug')) {
	log.debug('My debug log', { complexDataAsOneField: JSON.stringify(data) });
}

Breaking changes from V3 to V4

  • Log level verbose renamed to log level trace
  • JSON Format is enabled by default, it wasn't before
  • Remove transports features
  • Filters function change their signatures