cloudwatch-console-logger
v1.0.0
Published
cloudwatch-console-logger
Downloads
6
Maintainers
Readme
Cloudwatch Console Logger
Getting started
This creates a global logger
variable with the option to overide the console
in an aws enviornment to print objects rather than strings.
This is useful when using loggly.com
yarn add cloudwatch-console-logger
Example Usage
import CloudwatchConsoleLogger from 'cloudwatch-console-logger'
// initialize what you want to be added to each console.* or logger.* statment
CloudwatchConsoleLogger.init({
awsLambdaFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
awsRegion: process.env.AWS_REGION,
timeZone: process.env.TZ,
enviornment: process.env.STAGE,
prNumber: process.env.PR || 'UNDEF',
cookies: event.headers.Cookie,
headers: event.headers,
hostName: event.headers.Host
});
logger.info(`Hello world`);
/*
prints on server side only
{
// initial data
awsLambdaFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
awsRegion: process.env.AWS_REGION,
timeZone: process.env.TZ,
enviornment: process.env.STAGE,
prNumber: process.env.PR || 'UNDEF',
cookies: event.headers.Cookie,
headers: event.headers,
hostName: event.headers.Host,
// more data
message: "Hello world"
// and more, like line number.
}