tvloggertest
v0.0.1
Published
Logging across different environments such as AWS, GCP, and Local
Downloads
4
Readme
TechVedika-NodeJS-CommonModules
@techv/logger
@techv/logger is a versatile logging package designed to handle various logging needs in your applications. It supports multiple logging targets, including local file systems, AWS CloudWatch, and Google Cloud Logging, making it suitable for a range of deployment environments
Installation
npm i @techv/logger
Set Up
Before using the package, ensure that the necessary environment variables
are set according to your logging target:
Mention type of the log
LOGGER_TYPE = "AWS" // use can use `LOCAL` and `GCP`
AWS
AWS_LOG_GROUP_NAME: The name of the CloudWatch log group.
AWS_LOG_STREAM_NAME: The name of the CloudWatch log stream.
AWS_ACCESS_KEY_ID: Your AWS access key ID.
AWS_SECRET_ACCESS_KEY: Your AWS secret access key.
AWS_SESSION_TOKEN: (Optional) Your AWS session token.
AWS_DEFAULT_REGION: The AWS region where CloudWatch logs are stored.
RETENTION_IN_DAYS: The number of days to retain logs.
GCP
GOOGLE_APPLICATION_CREDENTIALS: Path to your Google Cloud service account credentials file.
GCP_PROJECT: Your Google Cloud project ID.
LOG_NAME: The name of the log in Google Cloud Logging.
Log Type Specify the type of logging target using the LOGGER_TYPE constant:
"LOCAL": Logs messages to the local file system.
"AWS": Logs messages to AWS CloudWatch.
"GCP": Logs messages to Google Cloud Logging.
`
Usage:
let loggerInstance = new TechvLogger();
loggerInstance.logger(level, message, headers, payload, additionalInfo)
Example
loggerInstance.logger(
'error',
'log test',
{ userId: 1, userName: 'Checking' },
{ id: 1, transaction: 'testing data details' },
{ method: 'gethello', controller: 'appcontroller', trace: 'tracing....' }
);
Publish
for contributers you need to have an npm account below are the steps to publish
npm login
npm publish