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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@heathmont/node-logger

v2.1.0

Published

node-logger

Readme

Simple logging library for node projects

Main purpose for this library is having streamlined logging logic, like in production output would be in JSON and while developing it's output is simpler with better readability (default winston console). Library has two main components, logger and loggerExpress (express' middleware, which is easy to plug in).

Environment variables

  • LOG_SERIALIZATION = json | text - when json is set, log output will be json serialized, text otherwise
  • NODE_ENV = production | development - when production is set only info, warn and error levels are logged and for loggerExpress only erroneous response codes (>400) will be logged.
  • LOG_LEVEL = debug | info | warn | error - set log level without having to change NODE_ENV of your application
  • LOG_SANITIZATION = true - if not specified, sanitization depends on NODE_ENV: disabled for development, enabled for production. Setting this to true forces sanitization on in non-production environments. Production sanitization is always on and cannot be disabled via this flag.
  • LOG_SANITIZE_CUSTOM_FIELDS = field1,field2,field3 - sanitize additional fields (when sanitization is enabled), defined as a comma-separated list of field names

logger

Logger adds metadata for instance (like host), replaces sensitive meta fields (like password) with asterisk.

Usage

It has typical logging functions like:

logger.init({ prefix: 'myProject' }); // All the meta info will be prefixed with this key

logger.debug('This is verbose debugging message', { someMetaData: 'Like so', user: { username: 'someuser' } });
logger.info('This is informational', { someMetaData: 'Like so', username: 'something', password: 'secret123' });
logger.warn('This warns about something', { someMetaData: 'Like so' });
logger.error('Some kind of error, things went bad', { someMetaData: 'Like so', username: 'something', password: 'secret123' });

loggerExpress

It adds metadata for:

  • instance's hostname (os.hostname()) as host
  • request
    • request.headers[x-forwarded-for] as meta.request.xForwardedFor
    • request.headers.authorization without signature as meta.request.authorization
    • req.connection.remoteAddres as meta.request.remoteAddress
    • body content (for debugging when error occur)),
  • response
    • response.headers[content-length] as meta.response.contentLength
    • time duration how long does the serving took as meta.response.timeMs
Usage

As it's just express middleware you can simply import and use:

expressServer.use(loggerExpress);

Example json output

From express
{
  "timestamp": "2017-09-20T10:36:10.110Z",
  "level": "error",
  "host": "fdd9bb5a29dd",
  "method": "POST",
  "url": "\/graphql",
  "status": 400,
  "meta": {
    "request": {
      "xForwardedFor": "213.219.106.114, 172.68.182.194, 10.0.2.164",
      "body": {
        "id": "q7",
        "query": "query ...",
        "variables": {

        }
      }
    },
    "response": {
      "contentLength": 132,
      "timeMs": 8.024
    }
  }
}
From logger
{
  "@timestamp": "2017-09-20T10:36:10.110Z",
  "level": "error",
  "meta": {
    "stack": "GraphQLError: Cannot query field \"someRandomField\" on type \"SomeRandomType\".\n    at Object.Field (\/...\/FieldsOnCorrectType.js:66:31)\n    at Object.enter (\/...\/visitor.js:297:29)\n",
    "nodes": [
      {
        "selectionSet": null,
        "loc": {
          "start": 694,
          "end": 707
        },
        "directives": [

        ],
        "kind": "Field",
        "name": {
          "loc": {
            "start": 694,
            "end": 707
          },
          "kind": "Name",
          "value": "someRandomField"
        },
        "alias": null,
        "arguments": [

        ]
      }
    ],
    "locations": [
      {
        "line": 1,
        "column": 695
      }
    ],
    "positions": [
      694
    ],
    "source": {
      "name": "GraphQL request",
      "body": "query Application {...."
    },
    "message": "Cannot query field \"someRandomField\" on type \"SomeRandomType\"."
  },
  "host": "fdd9bb5a29dd",
  "message": "",
  "type": "live"
}