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

bene-logger

v1.1.7

Published

Logger library for Chronos.

Downloads

24

Readme

BENE Logger

The BENE Logger is a library, which wraps winston with default parameters to be sent to all log messages using the instance. It also provides the console.time and console.timeEnd functionality to the logger, so that your log messages contain durations. Additionally, it allows you to log to Elasticsearch directly.

Log levels

The log levels follow the syslog standard as laid out in RFC5424, and are as follows:

{ emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7 }

You can specify the logger to only log up to a certain log level, by passing in level to the options. For example to only log emerg, alert, crit, and error logs, pass in level: 'error'.

Example usage

A simple log message is shown below:

var BeneLogger = require('bene-logger');
var logger = new BeneLogger({ defaults: { foo: 'bar' } });

logger.info('entering the void', { boo: 'moo' });
// info: entering the void boo=moo, foo=bar

Another example showing the usage of the setDefaults method:

var BeneLogger = require('bene-logger');

var logger = new BeneLogger({ defaults: {alpha: 'bravo'}});

logger.setDefaults({charlie: 'delta'});

logger.info('calling phonetic alphabet');
// info: calling phonetic alphabet charlie=delta

Below is an example of a timed log message:

var BeneLogger = require('bene-logger');
var logger = new BeneLogger({ defaults: { process_id: 1337 } });

logger.time('db request');

// ... request here that takes 1234ms

logger.timeEnd('db request', { request_id: 42 });
// info: db request request_id=42, process_id=1337, duration=1234

An Elasticsearch example is shown below:

var BeneLogger = require('bene-logger');
var logger = new BeneLogger({
    defaults: { foo: 'bar' },
    elasticsearch: {
        indexPrefix: 'logs',
        indexSuffixPattern: 'YYYY.MM.DD',
        clientOpts: { host: 'http://localhost:9200' }
    }
});

logger.info('entering the void', { boo: 'moo' });
// info: entering the void boo=moo, foo=bar

For more options to pass into the elasticsearch property, refer here.