forked from Optum/mockiato
-
Notifications
You must be signed in to change notification settings - Fork 0
/
winston.js
35 lines (29 loc) · 1013 Bytes
/
winston.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
const fs = require('fs');
const winston = require('winston');
let filename = process.env.MOCKIATO_LOG_FILE || '/dev/null';
const transports = [ new winston.transports.Stream({
stream: fs.createWriteStream(filename)
})];
if (process.env.MOCKIATO_SPLUNK_ENABLED) {
const SplunkStreamEvent = require('winston-splunk-httplogger');
const splunkSettings = {
url: process.env.MOCKIATO_SPLUNK_URL,
index: process.env.MOCKIATO_SPLUNK_INDEX,
token: process.env.MOCKIATO_SPLUNK_TOKEN,
host: process.env.MOCKIATO_SPLUNK_HOST,
level: 'info',
sourcetype: 'mockiato:app_logs',
source:'mockiato',
ssl: 'true'
};
transports.push(new SplunkStreamEvent({ splunk: splunkSettings }));
}
logger = winston.createLogger({
transports: transports,
format: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp(),
winston.format.json()
),
});
module.exports = logger;