Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 793 Bytes

README.md

File metadata and controls

43 lines (29 loc) · 793 Bytes

Features

  • Simple and easy-to-use API
  • Log level filtering
  • Custom logger support
  • Works with both Browser and NodeJS

Installation

npm install rt0-logger

Basic Usage

import { Log } from 'rt0-logger';

const log = new Log('test/module');

log.d('test'); // [debug] [test/module] test

Set Log Level

import { Log, type LogLevel } from 'rt0-logger';

const logLevel: LogLevel = 'info';

function createLogger(label: string) {
  return new Log(label, {
    getLogLevel: () => logLevel
  });
}

const log: Log = createLogger('test/module');

log.d('test'); // won't log anything
log.i('test'); // [info] [test/module] test

Check the GitHub homepage for the complete documentation.