forked from lazywithclass/winston-cloudwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
24 lines (18 loc) · 794 Bytes
/
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
var util = require('util'),
winston = require('winston'),
cloudwatchIntegration = require('./lib/cloudwatch-integration');
var CloudWatch = winston.transports.CloudWatch = function(options) {
this.name = 'CloudWatch';
this.level = options.level || 'info';
this.logGroupName = options.logGroupName || 'default-log-group-name';
this.logStreamName = options.logStreamName || 'default-log-stream-name';
};
util.inherits(CloudWatch, winston.Transport);
CloudWatch.prototype.log = function(level, msg, meta, callback) {
var log = { level: level, msg: msg, meta: meta };
var conf = { logGroupName: this.logGroupName, logStreamName: this.logStreamName };
cloudwatchIntegration.upload(log, conf, function() {
callback(null, true);
});
};
module.exports = CloudWatch;