chensenlai 10988628a0 语音房项目初始化 | 5 anos atrás | |
---|---|---|
.. | ||
node_modules | 5 anos atrás | |
README.md | 5 anos atrás | |
index.js | 5 anos atrás | |
package.json | 5 anos atrás |
A really simple logger for web server or others.
npm install mini-logger
Log levels for logger is useless. Just let debug module handle the debug log. All you need is error log and some custom categories. mini-logger
just write logs into different files or stdout, do not care formats(only format Errors and Objects).
var path = require('path');
var Logger = require('mini-logger');
var logger = Logger({
dir: path.join(__dirname, 'logs'),
categories: [ 'http' ],
format: '[{category.}]YYYY-MM-DD[.log]'
});
logger.error(new Error('error'));
logger.http('http request url: %s', 'https://github.com');
{category}
will replace with logger category, default is [{category.}]YYYY-MM-DD[.log]
false
true
os.EOL + os.EOL
utf-8
flushInterval
ms flush into files. default is 1s
duration
ms. default is 1h
mkdirp
first. useful when format is like YYYY/MM/DD/[{category}.log]
, default to falseLogger will emit an error event when any write streams emit an error. If you don't listen this error
event, it will default hanlde by:
function onerror(err) {
console.error(err.stack);
}
MIT