forked from crowbartools/Firebot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorLogging.js
More file actions
35 lines (30 loc) · 1.01 KB
/
errorLogging.js
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var winston = require('winston');
require('winston-daily-rotate-file');
var dataAccess = require('./common/data-access.js');
var app = (electron.app || electron.remote.app);
var transport = new winston.transports.DailyRotateFile({
filename: dataAccess.getPathInUserData('/user-settings/logs')+'/log',
datePattern: 'yyyy-MM-dd.',
prepend: true,
json: false,
handleExceptions: false,
humanReadableUnhandledException: true,
exitOnError:false,
timestamp: function() {
return new Date().toTimeString();
},
formatter: function(options) {
return options.timestamp()+': v'+app.getVersion()+' : '+ options.level.toUpperCase() +' '+ (options.message ? options.message : '') + (options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
}
})
var logger = new (winston.Logger)({
transports: [
transport
]
});
function log(message){
logger.info(message);
console.log('Error logged: '+ message);
}
// Export
exports.log = log;