This is my attempt to write a serialized JSON logs with severity.
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=
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')
This library will reattempt once again when it fails with an sequence token error.