awslogs-stream
Stream to write logs to AWS CloudWatch.
This is actually a plain Node.js Writable object stream.
Usage
var bunyan = ;var CloudWatchStream = ;var stream =;var log = bunyan;
API
CloudWatchStream(opts)
With opts
of:
logGroupName
(required)logStreamName
(required)cloudWatchLogsOptions
(optional): options passed to theAWS.CloudWatchLogs
constructorcloudWatchLogs
(optional): optional existing cloudwatchlogs clientprocessLogRecord
(optional): function to process log records to for cloudwatch (it should return object with 2 properties:message
to be string andtimestamp
to be unix timestamp)bufferDuration
(optional, by default it is 5000 ms) timeout between writes
On write of the first log, the module creates the logGroup and logStream if necessary.
We use the aws-sdk to write the logs - the AWS credentials have therefore to be configured using environment variables (AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
).
- Configuring the aws-sdk
CloudWatchLogs.putLogEvents
is the method we use to write logs
Contributors
This project was created by Mirko Kiefer (@mirkokiefer) and almost rewritten by Denis Bardadym.