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

logginator

v1.5.0

Published

Creates an instance of TaggedLogger

Downloads

75

Readme

Installation

npm install logginator

Usage

var log = require('logginator')(config);
log.info("I am a log message");

Config

Optional. If left unspecified, logginator will default to console output.

To configure the backends, specify an array with the desired backend configurations, for example:

var log = require('logginator')([
  {
    "transport": "console"
  }, {
    "transport": "syslog"
  }
]);

console

To output logs to the console, use this configuration:

{
  "transport": "console"
}

Additional options are:

  • level: The minimum level of log messages to output to this logger, for example "info". Keep this unset to allow all messages that are accepted by the logger object
  • handleExceptions: Set to true to intercept unhandled exceptions and output them to this log target
  • exceptionsLevel: The log level at which to log exceptions. Defaults to "error"
  • humanReadableUnhandledException: Format exception log output in a more readable fashion

syslog

To output logs to syslog, this configuration is sufficient:

{
  "transport": "syslog"
}

Additional options are:

  • appname: The name this process should use to identify itself to syslog. By default, logginator tries to deduce the name of the node project that uses logginator as a module.
  • localhost: The hostname of the current machine, as sent to syslog. Defaults to os.hostname().
  • facility: The facility, in syslog terminology, that the logger should log to. This concept only makes sense in a syslog setting, so refer to syslog documentation if you want to make an informed choice. Otherwise, stick with the default value, which is "local0".
  • protocol: The protocol via which to log. The default, and recommended, value, is "unix", which makes logging go via Unix datagram sockets to the path specified in the path option. Other choices are "tcp4", "tcp6", "udp4" and "udp6", which all require host and port to be specified.
  • path: The path to log to when using "unix" for protocol. If not set, logginator will try to deduce the default system log pipe by trying /dev/log, /var/run/syslog and /var/run/log in order. If all of these fail, logginator will raise an exception.
  • host and port: The host and port pair for the TCP or UDP log target if using any other protocol than "unix". Note that the target syslog daemon must be configured to accept connections on the specified protocol.

slack

Configuration options:

  • webhook_url: required The webhook URL, something like https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ
  • level: If specified, this logger will only log messages at the specified level of importance and more important messages
  • custom_formatter: a function (level, msg, meta) which returns a Slack payload object

Additionally, you can specify any Slack message parameters (such as username and channel), and it will be applied as a fallback if the given argument is not specified per message.

For example, a valid configuration could look like this:

{
  "transport": "slack",
  "webhook_url": "https://hooks.slack.com/services/XX/YY/ZZ",
  "channel": "#test-channel",
  "username": "ErrorBot",
  "level": "error",
  "handleExceptions": true
}