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

@hackcapital/logger-nodejs

v1.1.7-ops

Published

It's a powerful logger built on top of Bunyan capable to write logs to stdout, file and send to LogStash out-of-the-box.

Downloads

6

Readme

node version status

logger

A powerful logger built on top of Bunyan capable to write logs to stdout, file and send to LogStash out-of-the-box.

Usage

There's a full functional example at the example/index.js file.

Features

  • Buffer milions of messages
  • Logs to Logstash, local FS and stdout
  • setTags() allows to dynamically append to the original set tags

Env Vars

  • process.env.NODE_DEBUG: If specified, produces a lot of noise
  • process.env.LOGGER_PLUGINS_LOCALFILE_ENABLED: If specified, enables the localfile plugin
  • process.env.LOGGER_PLUGINS_LOCALFILE_ROTATION: Set log file rotation. Default: 1d
  • process.env.LOGGER_PLUGINS_LOCALFILE_RETENTION: Set log file retention. Default: 5
  • process.env.LOGGER_PLUGINS_LOCALFILE_LOG_DIR_NAME: Default directory name. Default: logs
  • process.env.LOGGER_PLUGINS_LOCALFILE_MIN_LEVEL: Default: debug
  • process.env.LOGGER_PLUGINS_STDOUT_ENABLED: If specified, enables the stdout plugin
  • process.env.LOGGER_PLUGINS_STDOUT_MIN_LEVEL: Default: debug
  • process.env.LOGGER_PLUGINS_LOGSTASH_ENABLED: If specified, enables the logstash plugin
  • process.env.LOGGER_PLUGINS_LOGSTASH_HOST: Set the Logstash host
  • process.env.LOGGER_PLUGINS_LOGSTASH_PORT: Set the Logstash port
  • process.env.LOGGER_PLUGINS_LOGSTASH_MIN_LEVEL: Default: info

Levels

The log levels in bunyan are as follows. The level descriptions are best practice opinions of the author.

  • fatal (60): The service/app is going to stop or become unusable now. An operator should definitely look into this soon.
  • error (50): Fatal for a particular request, but the service/app continues servicing other requests. An operator should look at this soon(ish).
  • warn (40): A note on something that should probably be looked at by an operator eventually.
  • info (30): Detail on regular operation.
  • debug (20): Anything else, i.e. too verbose to be included in "info" level.
  • trace (10): Logging from external libraries used by your app or very detailed application logging.

Setting a logger instance (or one of its streams) to a particular level implies that all log records at that level and above are logged. E.g. a logger set to level "info" will log records at level info and above (warn, error, fatal).

Source: Bunyan Levels

Logger <-> Logstash Integration

Logstash can take actions based on levels and special tags. Follows the level vs action matrix:

| level | logstash | slack | email | pagerduty | |-------|:--------:|------:|-------|-----------| | debug | no | no | no | no | | info | yes | no | no | no | | warn | yes | no | no | no | | error | yes | yes | no | no | | fatal | yes | yes | yes | yes |

_Notes:

  • It requires Logstash to be already setup and integrated with these services
  • Logger connects via tcp with Logstash
  • If the Logstash server is not available, it will not block the Logger execution

Tips

  • Do no concat strings
  • Less is more, reduce noise
  • If Logstash is routing to ES, pay attention to mapping conflicts
  • Do not blindly log objects
  • Do not directly logging errors -> mapping conflicts.
  • Don't use these fields!
  • message
  • timestamp
  • level
  • name
  • hostname
  • pid
  • time
  • msg
  • src
  • Add "outputCapture": "std" to your VSCode launch.json to see logs in debug mode