0.1.11 • Published 5 years ago

@ingentis/log v0.1.11

Weekly downloads
14
License
ISC
Repository
gitlab
Last release
5 years ago

Description

Allows log levels to be disabled based on the build environment (e.g., disable debug logs in production).

Usage

Install the package.

$ npm i @ingentis/log

Import and configure the Log class at the entry point of your application.

import { Log } from '@ingentis/log';

Log.configure({ levels: 'warn|error' });

Send logs to the Log class as you would to the console class. If a log level was omitted from the configuration, corresponding logs will be ignored.

Log.info('This is an info log.'); // Will not appear.
Log.warn('This is a warn log.'); // Appears as normal.

Configuration

{
  levels: 'info|warn|error',
  tags: true
}
  • levels : string = 'debug|info|log|warn|error'

    Log levels delimited by a pipe (|). Log levels include:

    • debug
    • info
    • log
    • warn
    • error
  • tags : boolean = false

    If true, logs are prefixed with the name of the module. When your package is installed as a dependency, logs are prefixed with your package name instead.

    Log.debug('This is a log from index.js.');
    // [index] This is a log from index.js.

FAQ

What about dependencies using Log?

Configuration is scoped to the directory of the calling module; packages cannot affect other packages' logs.

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago