techvedika-logger
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

Setup

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"  # or `LOCAL` or `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_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:

const TechvLogger = require('@techv/logger');
let loggerInstance = new TechvLogger();
loggerInstance.logger(level, data);

Example

loggerInstance.logger(
    'info',
{
    headers: { userId: 1, userName: 'Checking' },
    data: { id: 1, transaction: 'testing data details' },
    additionalData: { method: 'gethello', controller: 'appcontroller', trace: 'tracing....' }
}
);

Publish

For contributors, you need to have an npm account. Follow the steps below to publish:

    npm login 
    npm publish

Readme

Keywords

none

Package Sidebar

Install

npm i techvedika-logger

Weekly Downloads

2

Version

0.0.1

License

UNLICENSED

Unpacked Size

44.7 kB

Total Files

34

Last publish

Collaborators

  • sowmyatechv