JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3794
  • Score
    100M100P100Q130217F
  • License MIT

A logging library for use in RokuCommunity tools

Package Exports

  • @rokucommunity/logger
  • @rokucommunity/logger/dist/index.js
  • @rokucommunity/logger/dist/transports/FileTransport
  • @rokucommunity/logger/dist/transports/FileTransport.js
  • @rokucommunity/logger/dist/transports/QueuedTransport
  • @rokucommunity/logger/dist/transports/QueuedTransport.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rokucommunity/logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@RokuCommunity/logger

A node.js logger library for use in the RokuCommunity projects.

build status coverage status monthly downloads npm version license Slack

Installation

npm

npm install @rokucommunity/logger

Usage

//import the logger
const logger = require('logger');
logger.logLevel = 'trace';
logger.error('Critical failure');
logger.warn('Something might be wrong');
logger.log('Normal message');
logger.info('Might be interesting');
logger.debug('Probably not interesting');
logger.trace('Definitely not interesting');

Output:

image

Advanced Usage

Log inheritance and Prefixing

A Logger instance can inherit settings from a parent, only needing to provide settings for the values it wants to override. All loggers inherit from the base Logger that is the default export from this module.

Consider the following example:

const logger = require('./dist');
logger.log('Hello from logger');

const childLogger = logger.createLogger({prefix: '[Child]'});
childLogger.log('Hello from childLogger');

const grandchildLogger = childLogger.createLogger({prefix: '[Grandchild]'});
grandchildLogger.log('Hello from grandchildLogger');

Output:

[14:38:30.429][LOG] Hello from logger
[14:38:30.432][LOG] [Child] Hello from childLogger
[14:38:30.432][LOG] [Child][Grandchild] Hello from grandchildLogger