-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (40 loc) · 1.33 KB
/
index.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
const winston = require('winston');
module.exports = logging;
function logging(sails) {
this.get = get;
return this;
/**
* Gets the logger for the provided name or the default logger
*
* @param {string} [name=names.default]
* @returns the logger
*/
function get(name = 'defaultLog') {
let loggerExists = winston.loggers.has(name);
if (loggerExists) {
return winston.loggers.get(name);
}
winston.loggers.add(name, {
file: {
filename: sails.config.logger.filepath + name + '.log',
json: false,
timestamp: () => { return new Date().toLocaleString(); },
maxsize: 5000000, // bytes 5MB files before swap
maxFiles: 30,
tailable: true,
zippedArchive: true, // Zip files after switch
level: sails.config.logger.level,
prettyPrint: true
},
console: {
silent: !sails.config.logger.console,
level: sails.config.logger.level,
json: false,
colorize: true,
timestamp: () => { return new Date().toLocaleString(); },
prettyPrint: true
}
});
return winston.loggers.get(name);
}
};