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

enrise-logger

v1.0.0

Published

Logger used within Enrise projects and module's

Downloads

24

Readme

Node.js logger module

build:? Coverage Status dependencies:? devDependencies:?

A simple wrapper around winston.

Installation

NPM: npm install enrise-logger --save
Yarn: yarn add enrise-logger

Initialization and usage

At the beginning of your application, be sure to initialize the logger:
require('enrise-logger')([config: Object]);

Where config is an optional object. See below for further instructions.

After the module is initialized, simply call .get(name: String) on the module to return a namespaced logger:
const log = require('enrise-logger').get('MyLogger');

The log object contains functions for each log-level:

  • log.info('Some log message');
  • log.error(new Error('Some error'));

.get(name: String, [level: String], [transportConfig: Object])

The .get() function allows additional customization. The level can overwrite the logging-level defined during initialization. A third argument can be passed to overwrite transport configuration. This will be merged onto the object passed to the transports.

Configuration

The default configuration looks as follows. Everything can be overwritten on initialization.

{
  winston: {
    transports: {
      Console: {
        level: 'info',
        colorize: true
      }
    },
    levels: {
      error: 0,
      warn: 1,
      help: 2,
      data: 3,
      info: 4,
      trace: 5,
      debug: 6,
      prompt: 7,
      verbose: 8
    }
  }
}

winston: Object

The top-level key winston in the config contains winston-specific configuration.

<namedloggerKey>: {level: String}

You can add other toplevel-keys to provide named-logger specific level-information. This functionality allows you to set the log-level through configuration.

{
  winston: {...},
  namedlogger1: {
    level: debug
  }
}

The above configuration would set the level of logging to debug for the logger which was created as follows:

const log = require('enrise-logger').get('NamedLogger1');

Be aware that the way you'll read and apply your config dictates the actions you should take to change the actual log-level at run-time. If you only read and apply the config at the start of your program you'd have to restart your program to apply the changed log-level.

winston.transports: Object

The keys define the transports that the logger should use, the value is the configuration passed to the transport constructor. Multiple transports can be combined. Defaults to only the Console with the settings above. To exclude the Console transport, set it to null. Possible transports are:

winston.levels

The node-logger uses more detailed log-levels than winston does. The higher the priority the more important the message is considered to be, and the lower the corresponding integer priority. These levels can be modified to your liking.