@nithinta/cloudwatch-logger

1.0.3 • Public • Published

AWS CloudWatch Logger

This is my attempt to write a serialized JSON logs with severity.

Configuration (.env file)

You need to setup log group and and stream in cloudwatch and fill all these in this .env file to start writing logs.

AWS_REGION= AWS_LOG_GROUP_NAME= AWS_LOG_STREAM_NAME= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY=

Sample script (example.js)

Contains a sample js file to write a log to cloudwatch.

require('dotenv').config(); const CloudWatchLogger = require('./index');

const region = process.env.REGION; const logGroupName = process.env.LOG_GROUP_NAME; const logStreamName = process.env.LOG_STREAM_NAME;

const logger = new CloudWatchLogger(region, logGroupName, logStreamName);

logger.writeLog('Warn', 'This is a test log message')

Retry log writing

This library will reattempt once again when it fails with an sequence token error.

Package Sidebar

Install

npm i @nithinta/cloudwatch-logger

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

4.05 kB

Total Files

5

Last publish

Collaborators

  • nithinta