Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enrise-logger

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enrise-logger

Logger used within Enrise projects and module's

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 08 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc