-
Notifications
You must be signed in to change notification settings - Fork 105
/
function-config.js
34 lines (31 loc) · 996 Bytes
/
function-config.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
var winston = require('winston');
WinstonCloudwatch = require('../index'),
crypto = require('crypto');
// Give ourselves a randomized (time-based) hash to append to our stream name
// so multiple instances of the server running don't log to the same
// date-separated stream.
var startTime = new Date().toISOString();
winston.loggers.add('access-log', {
transports: [
new winston.transports.Console({
json: true,
colorize: true,
level: 'info'
}),
new WinstonCloudWatch({
logGroupName: 'app-name',
logStreamName: function() {
// Spread log streams across dates as the server stays up
let date = new Date().toISOString().split('T')[0];
return 'express-server-' + date + '-' +
crypto.createHash('md5')
.update(startTime)
.digest('hex');
},
awsRegion: 'us-east-1',
jsonMessage: true
})
]
});
var logg = winston.loggers.get('access-log');
logg.info('This is a test');