Skip to main content

js logger

JavaScript and TypeScript logger for MapColonies based on pino.

API documentation

Check the autogenerated documentation here.

Usage

import jsLogger from '@map-colonies/js-logger';

const logger = jsLogger();

logger.info('hello world');

logger.error({hello: 'world'});

Logging errors

One of the features of the logger is the ability to parse error objects and format them accordingly. To allow the logger to identify the error, add it to the log object under the err key.

try {
// complex code
} catch (error) {
logger.error({msg: "oh noes", err: error});
}

For more detailed usage check the pino documentation.

Configuration

nametypedefault valuedescription
enabledbooleantruedetermines if logging is enabled
levelstring'info'specifies the logging level
redactarrayundefineddefines paths to redact from log output
hooksobjectundefinedhooks for customizing log behavior
baseobject{pid: process.pid, hostname: os.hostname}base properties to include in log output
mixinfunctionundefinedfunction to add custom properties to log output
prettyPrintbooleanfalseenables pretty-printing of log output
pinoCallerbooleanfalseincludes the caller's file and line number in log output
note

This page was generated from a remote source. you can find it on https://github.com/MapColonies/js-logger/blob/master/README.md