@aptoma/lambda-logger
v1.0.1
Published
Module for logging to CloudWatch and Grimm from an AWS Lambda function
Downloads
9
Readme
@aptoma/lambda-logger
Lambda logger is Node.js module for logging events on AWS Lambda, designed for use with AWS CloudWatch Logs.
Installation
$ npm install --save @aptoma/lambda-logger
Usage
const createLogger = require('@aptoma/lambda-logger');
const log = createLogger('my-service-name');
log.info('Hello World!', {meta: 'data'});
// { msg: 'Hello World!', _tags: [ 'log', 'info' ] }
Log Timer Events
You can use @aptoma/node-timer to log duration of some process:
const createLogger = require('@aptoma/lambda-logger');
const log = createLogger('my-service-name');
const timer = require('@aptoma/node-timer');
const elapsed = timer('SomeEvent');
// Do something slow ...
log.timerEvent(elapsed());
// { msg: 'SomeEvent: 215.489ms', _tags: [ 'log', 'info' ] }
Grimm Integration
For extra cred, send your timer events to Grimm, using @aptoma/grimm-pusher:
const createLogger = require('@aptoma/lambda-logger');
const createGrimmService = require('@aptoma/grimm-pusher').createService;
const grimmService = createGrimmService({
host: 'https://grimm.example.com',
apikey: 'reaper'
});
const log = createLogger('my-service-name', grimmService);
const timer = require('@aptoma/node-timer');
const elapsed = timer('SomeEvent');
// Do something slow ...
log.timerEvent(elapsed());