numo-labs / aws-lambda-helper

:lollipop: Collection of helper methods for lambda
GNU General Public License v3.0
22 stars 2 forks source link

Adding JSON logging as a function. #31

Closed tomgco closed 8 years ago

tomgco commented 8 years ago

This commit introduces a new method of logging from within AWS Lambda's.

It delegates to Bunyan and produces log messages in the structure defined below:

{
    "name": "aws-canary-lambda",
    "invokedFunctionArn": "arn:aws:lambda:eu-west-1:123456789:function:aws-canary-lambda:1",
    "traceableId": "some-id",
    "module": "where-i-am-from",
    "hostname": "magellanic",
    "version": "1",
    "pid": 25728,
    "level": 30,
    "msg": "hello in stdout",
    "time": "2016-05-06T11:48:44.207Z",
    "v": 0
}

As seen above this function also reads the current context of the lambda and populates some common fields to embelish logs with some added features, which could be indexed if sent to Elasticsearch.

codecov-io commented 8 years ago

Current coverage is 100%

Merging #31 into master will increase coverage by +n/a%

@@           master   #31   diff @@
===================================
  Files           1     1          
  Lines          76    85     +9   
  Methods         0     0          
  Branches        0     0          
===================================
+ Hits           76    85     +9   
  Misses          0     0          
  Partials        0     0          

Powered by Codecov. Last updated by c7d55f5...6a67bea

tomgco commented 8 years ago

As a note, the dependency bunyan is 492KB on disk when it is installed with npm install --no-optional and 4.8MB when installed with all dependencies.

tomgco commented 8 years ago

Review with @plaenen, let's rename the attribute: module: String to either tags: Array or labels: Array by passing in an array to the constructor.

jruts commented 8 years ago

@tomgco looks good. Can you update the package version so we can npm publish after merging? Thanks!

tomgco commented 8 years ago

@tomgco looks good. Can you update the package version so we can npm publish after merging?

Thanks, updated the minor version number.