pico-aws-cwlog

0.2.7 • Public • Published

pico-aws-cwlog

A pico sized aws cloudwatch logging library for nodejs

installation

npm i aws-sdk pico-aws-cwlog

pico-aws-cwlog required following environment variables

  • AWS_ACCESS_ID
  • AWS_ACCESS_KEY
  • AWS_DEFAULT_REGION

usage

need to create logger in early of your app lifetime

// index.js
const AWS = require('aws-sdk')
const pLog = require('pico-aws-cwlog')

// for additional aws config, see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
AWS.config.update({
	timeout: 5000
})

// pLog(GroupName, Options)
pLog('main', {
	uploadInterval: 60000, // log sync interval to aws cloudwatch
	uploadBatchSize: 10000, // max log count sync interval
	streams: ['error', 'log'] // number of streams to be created
})

// controller.js
const logger = require('pico-aws-cwlog')('main')
// const logger = require('pico-aws-cwlog')() // if only 1 group

logger.error({code: 400, msg: 'messgae'})
logger.log({debug: 'messgae'})
logger.warn({debug: 'messgae'}) // error, not defined in streams

test

npm test

Readme

Keywords

Package Sidebar

Install

npm i pico-aws-cwlog

Weekly Downloads

1

Version

0.2.7

License

MIT

Unpacked Size

7.87 kB

Total Files

5

Last publish

Collaborators

  • ldarren