0.0.4 • Published 7 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:
levelerror, warn, info, verbose, debug
isLocaltrue: logger will logged over the local console (server terminal)false: will log in both AWS cloudwatch as well as server terminal
falsebelow configuration details are manditory`logGroupNameCloudwatch log groupname: string
logStreamNameCloudwatch log streamname: string
regionAWS region: string
accessKeyIdAWS access key ID: string
secretAccessKeyAWS secret key: string
uploadRateTime interval at which the logs are uploaded into cloudwatch: number
retentionInDaysTime duration in days at which the logs are saved in cloudwatch: number
retryCountNumber 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
});