mirror of
https://github.com/franjsco/trackmyd-bot
synced 2025-06-05 22:19:29 +02:00
add logger
This commit is contained in:
32
logger.js
Normal file
32
logger.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
const bunyan = require('bunyan');
|
||||||
|
const config = require('./config.json');
|
||||||
|
|
||||||
|
const log = bunyan.createLogger({
|
||||||
|
name: config.app.name,
|
||||||
|
streams: [{
|
||||||
|
level: 'info',
|
||||||
|
path: config.logger.infoLogging.filename,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
function logError(msg) {
|
||||||
|
log.error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logInfo(msg) {
|
||||||
|
log.info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logFatal(msg) {
|
||||||
|
log.fatal(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logConsole(msg) {
|
||||||
|
console.log(`(${config.app.name}): ${msg}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.logError = logError;
|
||||||
|
module.exports.logInfo = logInfo;
|
||||||
|
module.exports.logFatal = logFatal;
|
||||||
|
module.exports.logConsole = logConsole;
|
Reference in New Issue
Block a user