2.1.1 • Published 1 year ago

@apolitical/logger v2.1.1

Weekly downloads
99
License
MIT
Repository
-
Last release
1 year ago

Apolitical Logger

Node.js module to expose Apolitical's logger service

Requirements

Requires the following to run:

Installation

Install with yarn:

yarn add apolitical-logger

Usage

First of all, include apolitical-logger module:

const apoliticalLogger = require('apolitical-logger');

The recommended way to use apolitical-logger is to create your own logger with the appropriate parameters:

const opts = { logLevel: 'info' };
const logger = apoliticalLogger(opts);

logger.info('Hello World!');

The where function

When debugging, it might be useful to also use the where function to track the location of your logs.

It accepts filename and method parameters, and it creates a child logger:

const opts = { logLevel: 'debug' };
const logger = apoliticalLogger(opts);

const childLogger = logger.where(__filename, 'debugging');
childLogger.debug('Accessed:', { count: 0 });

The labels object

And also, the labels allow you to keep extra info along the logger journey:

const opts = {
  labels: {
    name: 'apolitical-service',
    version: 'v1.0.0'
  }
};
const logger = apoliticalLogger(opts);
logger.info('Service Name');

Logging levels

The supported logging levels are:

{
  error: 0,
  warn: 1,
  info: 2,
  debug: 3
}
2.1.1

1 year ago

2.1.0

1 year ago

2.0.2

2 years ago

2.0.0-beta.7

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0-beta.0

2 years ago

2.0.0-beta.6

2 years ago

2.0.0-beta.5

2 years ago

2.0.1

2 years ago

2.0.0-beta.4

2 years ago

2.0.0

2 years ago

2.0.0-beta.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago