0.0.4 • Published 6 years ago
cloudwatch-logging v0.0.4
cloudwatch-logging
A simple Asynchronous cloud watch logging mechanism with an extended Console logger. This package is based on reference from aws4 and winston logger
Table of Contents
How to install?
npm install cloudwatch-logging --save
Using logger
You can import logger with default configuration that will log in your server console.
const { logger } = require('cloudwatch-logging')
logger.info('This is a info message from logger')
Note: Logger level is set to info
by default, you can update the level by updating the logger config.
Configuration
You can modify the available list of configuration at any point of time that will update the logger config across the whole application
Configurations available:
level
error, warn, info, verbose, debug
isLocal
true: logger will logged over the local console (server terminal)
false: will log in both AWS cloudwatch as well as server terminal
false
below configuration details are manditory`logGroupName
Cloudwatch log groupname: string
logStreamName
Cloudwatch log streamname: string
region
AWS region: string
accessKeyId
AWS access key ID: string
secretAccessKey
AWS secret key: string
uploadRate
Time interval at which the logs are uploaded into cloudwatch: number
retentionInDays
Time duration in days at which the logs are saved in cloudwatch: number
retryCount
Number of retries required if the AWS cloudwatch server is unreachable: number
Updating config
You can update the logger config by using one the below mentioned ways:
const { config } = require('cloudwatch-logging');
config({
level: 'debug',
isLocal: true
});
or
const cloudWatchLogger = require('cloudwatch-logging');
cloudWatchLogger.config({
level: 'debug',
isLocal: true
});