-
Notifications
You must be signed in to change notification settings - Fork 0
Options
Grant Carthew edited this page Oct 25, 2024
·
45 revisions
The following options can be changed when creating a log object. None of these options are required due to the default values:
| Name | Type | Default |
|---|---|---|
| levels | Object | Default Levels (see below) |
| level | String | 'info' |
| levelKey | String | 'level' |
| levelKeyEnabled | Boolean | true |
| levelNumberKey | String | 'lvl' |
| levelNumberKeyEnabled | Boolean | true |
| dateTimeKey | String | 'time' |
| dateTimeFunction | Function | () => Date.now() // epoch time |
| messageKey | String | 'msg' |
| dataKey | String | 'data' |
| separatorString | String | ':' |
| serializers | Object | false (disables serializers) |
| serializeErrorFunction | Function | serialize-error |
| stringifyFunction | Function | stringify |
| passThrough | Boolean | false |
| write | Function | process.stdout.write |
Following is an example of the options object being used to create a logger object. The options are simply being set to their default value on Node.js. This is just to show the syntax:
import Perj from 'perj'
const logOptions = {
levels: {
fatal: 60,
error: 50,
warn: 40,
info: 30,
debug: 20,
trace: 10
},
level: 'info',
levelKey: 'level',
levelKeyEnabled: true,
levelNumberKey: 'lvl',
levelNumberKeyEnabled: true,
dateTimeKey: 'time',
dateTimeFunction: () => Date.now(),
messageKey: 'msg',
dataKey: 'data',
separatorString: ':',
serializers: false,
serializeErrorFunction: () => { /* Custom Function */ },
stringifyFunction: JSON.stringify,
passThrough: false,
write: process.stdout.write.bind(process.stdout)
}
const log = new Perj(logOptions)