3.0.0-rc.10 • Published 9 months ago

@debugr/console v3.0.0-rc.10

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Console Handler for Debugr

This Handler adds logging to console.

Installation

npm install --save @debugr/console

Usage

import { Logger, LogLevel } from '@debugr/core';
import { ConsoleHandler } from '@debugr/console';

const globalContext = {
  applicationName: 'example',
};

const logger = new Logger(globalContext, [
  new ConsoleHandler(),
]);

logger.info('Application started.');

// will output something like:
// [ii] Application started.

Options

The ConsoleHandler constructor accepts an optional options object with the following keys as the first argument:

OptionTypeDefaultDescription
thresholdLogLevelLogLevel.INFOThe lowest level of entries which will be logged. Any entries below this level will be ignored.
levelMapRecord<number, string>A map of custom log levels to their string representation.
colorMapRecord<number, (v: string) => string>A map of custom log levels to callbacks applying ANSI colors. See ansi-colors.
timestampboolean, (ts: ImmutableDate) => stringfalseWhether to prefix entries with their timestamp. Pass a callback if you need custom formatting.