lub-log
lub-log
is a log util when you create your own lub plugin.
It supports several log types usually needed.
debug
log
info
warn
error
success
wait
start
watch
Install
$ npm i lub-log --save
Usage
Basic
Setting your scope when require lub-log
and log:
const lubLog = 'hello'; lubLog;lubLog;lubLog;lubLog;lubLog;lubLog;lubLogstart'Hello' 'world';lubLog;
debug
method is based on debug, you scope name will be passed as debug's module name
Advanced
You can also pass more configs into lub-log
,to log some useful info like date, time, filename:
const lubLog = scope: 'hello' 'lub-log' config: displayDate: true displayTimestamp: true displayFilename: true displayLabel: true displayBadge: true underlinePrefix: true uppercaseLabel: true underlineLabel: true underlineMessage: true underlineSuffix: true ; lubLog;lubLog;lubLog;lubLog;lubLog;lubLog;lubLogstart'Hello' 'world';lubLog;
API
<logger>(message[, message]|messageObj|errorObj)
lubLog.logger
- type:
Function
One of several log types usually needed mentioned above.
message
- type:
String
Can be one or more comma delimited strings.
They will be formated by Nodejs's util lib;
const lubLog = ; lubLog;//=> ✔ success Successful operation lubLog;//=> ✔ success Successful operation lubLog;//=> ✔ success Successful operation
messageObj
- type:
Object
A object with prefix
, message
and suffix
props.
const lubLog = ; lubLogcompleteprefix: '[webpack]' message: 'build successfully' suffix: 'index.js';//=> [webpack] ☒ complete build successfully index.js
errorObj
- type:
Error Object
When you pass an error object, lub-log
will log stack info:
const lubLog = ; lubLog;//=> ✖ error Error: Unsuccessful operation// at Module._compile (module.js:660:30)// at Object.Module._extensions..js (module.js:671:10)// ...
scope(name[, name])
lubLog.Defines the scope name of the logger.
name
- type:
String
unscope()
lubLog.Clear the scope name of the logger.
config(setting)
lubLog.Defines the setting config of the logger.
setting
- type:
Object
The default config value is:
displayDate: false displayTimestamp: false displayFilename: false displayLabel: true displayBadge: true underlinePrefix: false uppercaseLabel: false underlineLabel: false underlineMessage: false underlineSuffix: false