bbb-webrtc-sfu now rotates logs daily

This commit is contained in:
prlanzarin 2018-01-30 13:50:43 +00:00
parent 281a14baf8
commit 5e384e2d4a
4 changed files with 34 additions and 16 deletions

View File

@ -17,4 +17,3 @@ to-audio: "to-audio-sfu"
log: log:
filename: '/var/log/bigbluebutton/bbb-webrtc-sfu/bbb-webrtc-sfu.log' filename: '/var/log/bigbluebutton/bbb-webrtc-sfu/bbb-webrtc-sfu.log'
level: 'verbose' level: 'verbose'
maxSize: 100000000

View File

@ -1,17 +1,14 @@
'use strict'; 'use strict';
/**
* @classdesc
* Logger singleton for mcs-sip
* @memberof mcs-sip
*/
const Winston = require('winston'); const Winston = require('winston');
const Logger = new Winston.Logger(); const Logger = new Winston.Logger();
const config = require('config'); const config = require('config');
const path = require('path'); const path = require('path');
Winston.transports.DailyRotateFile = require('winston-daily-rotate-file');
const LOG_CONFIG = config.get('log') || {}; const LOG_CONFIG = config.get('log') || {};
const { level } = LOG_CONFIG;
let filename = LOG_CONFIG.filename;
Logger.configure({ Logger.configure({
levels: { error: 0, warn: 1, info: 2, verbose: 3, debug: 4 }, levels: { error: 0, warn: 1, info: 2, verbose: 3, debug: 4 },
@ -31,22 +28,20 @@ Logger.add(Winston.transports.Console, {
colorize: true, colorize: true,
handleExceptions: false, handleExceptions: false,
silent: false, silent: false,
stringify: (obj) => JSON.stringify(obj) stringify: (obj) => JSON.stringify(obj),
level,
}); });
let filename = LOG_CONFIG.filename || path.join(process.env.PWD, 'mcs-sip.log');
if (filename) { if (filename) {
Logger.add(Winston.transports.File, { Logger.add(Winston.transports.DailyRotateFile, {
filename, filename,
prettyPrint: true, prettyPrint: true,
timestamp:true, datePattern: '.yyyy-dd-MM',
prepend: false,
stringify: (obj) => JSON.stringify(obj), // single lines stringify: (obj) => JSON.stringify(obj), // single lines
maxsize: LOG_CONFIG.maxSize || '100000000' // 100MB default level,
}); });
} }
Logger.transports.console.level = LOG_CONFIG.level;
Logger.transports.file.level = LOG_CONFIG.level;
module.exports = Logger; module.exports = Logger;

View File

@ -225,6 +225,21 @@
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}, },
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
"moment": { "moment": {
"version": "2.20.1", "version": "2.20.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.20.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.20.1.tgz",
@ -403,6 +418,14 @@
} }
} }
}, },
"winston-daily-rotate-file": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/winston-daily-rotate-file/-/winston-daily-rotate-file-1.7.2.tgz",
"integrity": "sha1-ZQK/opeCT9mC2l5WR8dThXjS+aA=",
"requires": {
"mkdirp": "0.5.1"
}
},
"ws": { "ws": {
"version": "3.3.2", "version": "3.3.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.3.2.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.2.tgz",

View File

@ -15,7 +15,8 @@
"ws": "^3.3.2", "ws": "^3.3.2",
"config": "^1.26.1", "config": "^1.26.1",
"js-yaml": "^3.8.3", "js-yaml": "^3.8.3",
"winston": "^2.4.0" "winston": "^2.4.0",
"winston-daily-rotate-file": "^1.7.2"
}, },
"optionalDependencies": {} "optionalDependencies": {}
} }