-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.js
40 lines (33 loc) · 883 Bytes
/
app.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
const {createLogger, transports, format } = require('winston');
const { combine, timestamp, label, prettyPrint, json } = format;
const logstashTcpWins = require('./index.js');
const logstashTransport = new logstashTcpWins({
level: "debug",
port: 5000,
json: true,
host: "localhost",
retryInterval: 2000,
maxRetries: 1000,
label: "MyTestLabel",
});
logstashTransport.on('error', (error)=>console.error('logstash transport error',error));
const logger = createLogger({
format: combine (
label({ label: 'right meow!' }),
timestamp(),
prettyPrint(),
json()
),
transports: [
logstashTransport
],
exitOnError: false
});
logger.on('error', (error)=>console.warn('logstash error', error));
let x = 0;
setInterval(() => {
logger.debug({
stuff:"Hi!",
id: x++
});
},100)