Skip to content

Commit

Permalink
formatLogItem should return an object
Browse files Browse the repository at this point in the history
in README.md it says that you can pass a function to formatLogItem that returns a string, but that doesn't work. The formatLogItem expects a function that returns an object with a message and timestamp. If only a string is returned it throws an error and no logs are sent to AWS CloudWatch. 

I found this fix in `cloudwatch-event-formatter.js:32` in which the formatLogItem function is returning an object that has a `message` and `timestamp`. It took me a while to find this  though because the documentation in README.md says that you only need to return a string.
  • Loading branch information
mujz committed Jul 9, 2016
1 parent 04c0113 commit ef6392c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ winston.add(CloudWatchTransport, {
region: '...'
},
formatLogItem: function (item) {
return item.level + ': ' + item.message + ' ' + JSON.stringify(item.meta)
return {
message: item.level + ': ' + item.message + ' ' + JSON.stringify(item.meta),
timestamp: item.date
}
}
})
```
Expand Down

0 comments on commit ef6392c

Please sign in to comment.