bellman
v1.1.12
Published
Yet another console logger. A pretty and powerful one, though.
Downloads
17
Readme
Bellman
Yet another console logger. A pretty and powerful one, though.
yarn add bellman
Methods
reg
- registers the file from which logging methods will be called to adjust the width of the:caller
row
Default config
const Logger = require('bellman')
new Logger()
.reg()
.info('info message')
.debug('debug message')
.warn('warning message')
.error('error: %s', new Error())
Custom config
const Logger = require('bellman')
const userConfig = {
timeTmp: 'HH:mm',
lineTmp: ':level :time :caller :message',
colorize: true,
callerColor: 'yellow.bold',
levelMap: {
debug: 'blue',
info: 'green',
panic: 'red'
},
levelMin: 'debug',
isFullStack: true
}
new Logger(userConfig)
.reg()
.info('info line')
.debug('debug line')
.panic('panic line: %s', new Error())
Config
lineTmp
- sets the logging line format. Supported placeholders::time
- a timestamp in the format defined by thetimeTmp
config option:level
- a name of the logging method that has been called:caller
- a name of the file and a number of the line from which the logging method has been called:message
- a formatted message combined from the arguments passed to the logging method (util.format is used to fromat messages)
timeTmp
- sets the timestamp format (moment is used to format timestamps)colorize
- overrides whether the coloring should be used or not (chalk is used for colorization)callerColor
- sets the:caller
part color.levelMap
- sets the names, priorities, and colors of the logging methodslevelMin
- sets the logging levelisFullStack
- sets whether the error stack formatter should be used or not- if unset, all the lines that refer files out of the project's directory and all the files within
node_modules
directories will be removed - if set, no modifications will be applied to the error-stacks
isFullStack
may be overridden withSTACK=full
andFULLSTACK=true
environment variables
- if unset, all the lines that refer files out of the project's directory and all the files within
Events
log
- emits metadata of a logged line:time
- a formateed timestamplevel
- a name of the logged message that has been calledcaller
- a name of the file and a number of the line from which the logging method has been calledmessage
- a formatted messageargs
- arguments passed the logged message