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
name | type | default value | description |
---|---|---|---|
enabled | boolean | true | determines if logging is enabled |
level | string | 'info' | specifies the logging level |
redact | array | undefined | defines paths to redact from log output |
hooks | object | undefined | hooks for customizing log behavior |
base | object | {pid: process.pid, hostname: os.hostname} | base properties to include in log output |
mixin | function | undefined | function to add custom properties to log output |
prettyPrint | boolean | false | enables pretty-printing of log output |
pinoCaller | boolean | false | includes 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