$ npm install @deepak-delta/logforge
The default settings are:
- colorize: false
- log: [ISO timestamp] [level] [message] [category] [metadata]
// /app/index.js
import { logger } from 'logforge'
logger.info('App', 'Application started', {
version: '1.0.0',
environment: 'production',
})
output
{"timestamp":"2024-04-01T10:31:15.174Z","level":"DEBUG","category":"App","message":"Application started","metadata":{"version":"1.0.0","environment":"production"}}
The default configuration can be changed by creating lfconfig.json
file in the root directory of the project
lfconfig.json
{
"writeToFile": "false",
"logFilePath": "",
"timeStamp": "false",
"setColor": "true"
}
Name | Type | Default value | Description |
---|---|---|---|
writeToFile | Boolean | fasle | Output the log to file |
logFilePath | String | null | Path of log file |
timeStamp | Boolean | true | Turns on/off the timestamp |
setColor | Boolean | false | Turns on/off the colorized output |
- loglevel - valid values are
info
,error
,warn
, anddebug
Feel free to open an issue on github.
Great! fork this repository and make a pull request😊.