Logging library for node.js.
issue: Github repository issue tabs
feature: Github repository pull request tabs
Issue and Pull requests are always open.
const path = require('path');
const lug = require('lug-log');
const logger = lug.createLogger({
strategies: [
new.lug.DailyStrategy({
level: 'info',
path: path.join(__dirname, '/log'),
filename: '%DATE%.log',
}),
new.lug.DailyStrategy({
level: 'error',
path: path.join(__dirname, '/log/error'),
filename: '%DATE%.error.log',
}),
],
formatter: (log) => {
return `${log.level} - ${log.message}`;
}
});
logger.info('some log')
debug
info
warn
error
fatal
export type LogLevels =
'debug'
| 'info'
| 'warn'
| 'error'
| 'fatal'
You can set how to write logs with logging strategy.
DailyStrategy creates a new log file each day.
option | description | default | required |
---|---|---|---|
level | Minimum level this strategy will write | debug | X |
path | The path that log files will be created (Absolute path) | X | O |
filename | File name to save '%DATE%' must contain. It will replace 'yyyy-MM-dd' |
%DATE%.log | X |
new.lug.DailyStrategy({
level: 'info',
path: path.join(__dirname, '/log'),
filename: '%DATE%.log',
}),
You can make a form of logs. Set option of function createLogger
.
target | type |
---|---|
argument | Log |
return value | string |
attributes | type | description |
---|---|---|
level | LogLevels | Log level |
message | string | Log message |
timestamp | number | Log timestamp |
(log) => {
return 'format your custom log';
}
[level] - yyyy-MM-dd HH:mm:ss message