bigbluebutton-Github/bigbluebutton-html5/imports/startup/server/logger.js

51 lines
1.0 KiB
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import Winston from 'winston';
2017-06-03 03:25:02 +08:00
const Logger = new Winston.Logger();
2016-12-01 00:29:13 +08:00
Logger.configure({
2018-01-08 08:25:56 +08:00
levels: {
error: 0, warn: 1, info: 2, verbose: 3, debug: 4,
},
2016-12-01 00:29:13 +08:00
colors: {
error: 'red',
warn: 'yellow',
info: 'green',
verbose: 'cyan',
debug: 'magenta',
},
});
// Write logs to console
Logger.add(Winston.transports.Console, {
2016-10-18 20:03:51 +08:00
prettyPrint: false,
humanReadableUnhandledException: true,
colorize: true,
2016-10-18 20:03:51 +08:00
handleExceptions: true,
});
Meteor.startup(() => {
const LOG_CONFIG = Meteor.settings.private.log || {};
2018-01-08 08:25:56 +08:00
let { filename } = LOG_CONFIG;
2016-12-02 00:15:57 +08:00
// Set Logger message level priority for the console
Logger.transports.console.level = LOG_CONFIG.level;
// Determine file to write logs to
if (filename) {
if (Meteor.isDevelopment) {
const path = Npm.require('path');
filename = path.join(process.env.PWD, filename);
}
Logger.add(Winston.transports.File, {
2017-06-03 03:25:02 +08:00
filename,
prettyPrint: true,
});
}
});
export default Logger;
2017-06-03 03:25:02 +08:00
export const logger = Logger;