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
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
});
logger.info('Hello world');
/*
prints on server side only
{
// initial data
awsLambdaFunctionName: "myLambdaFunction",
awsRegion: "some region",
timeZone: "some time zone",
// more data
message: "Hello world"
}