-
Notifications
You must be signed in to change notification settings - Fork 54
/
etl-file-logger.js
executable file
·54 lines (47 loc) · 1.22 KB
/
etl-file-logger.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
var winston = require('winston');
var path = require('path');
var _ = require('underscore');
var moduleDefinition = {
logRequestError: logRequestError,
logger: logger
};
module.exports = moduleDefinition;
function logRequestError(message, fileName, absolutePath) {
var logger = new winston.Logger({
transports: [
new winston.transports.File({
level: 'error',
filename: fileName || 'server-request-logs.log',
handleExceptions: true,
json: true,
colorize: false
})
],
exitOnError: false
});
logger.add(require('winston-daily-rotate-file'), {
filename: absolutePath + fileName || 'server-request-logs.log'
});
logger.error(message);
logger.close();
}
function logger(filePath) {
var fileName = path.basename(filePath);
var logger = new winston.Logger({
transports: [
new winston.transports.File({
level: 'error',
filename: fileName || 'server-request-logs.log',
handleExceptions: true,
json: true,
colorize: false
})
],
exitOnError: false
});
logger.add(require('winston-daily-rotate-file'), {
filename: filePath || 'server-request-logs.log'
});
return logger;
}