@plmtest/plmtrustlink-logger
v1.0.3
Published
Package that provides a common logger
Readme
PLM Fleet Logger
This package provides a consistent logging implementation for all PLM Fleet services (and packages).
Usage
Creating a new Logger
const { createLogger } = require('@plmtest/cosmos-logger')
const config = {
name: 'my-logger',
level: 'info'
}
const logger = createLogger(config)Configuration
Various options for the logger can be configured. By default, the following configuration is used:
const config = {
name: 'N/A',
level: LOG_LEVELS.INFO,
src: true,
mode: LOG_MODES.DEFAULT, // DEFAULT, SIMPLE, SHORT, LONG, JSON, INSPECT
color: true,
jsonIndent: 2
}Print logs based on the level and the message
log('error', {
name: 'service-sample',
tenantId: 'b2caf368-927f-4804-9131-5bf19ac07dac',
user: '[email protected]',
message: 'error occured',
err
})
log('info', {
name: 'service-sample',
tenantId: 'b2caf368-927f-4804-9131-5bf19ac07dac',
user: '[email protected]',
message: 'Hello',
}) 