@bolt.tech/logger
v1.0.11
Published
Leave all your logging worries to me.
Downloads
414
Keywords
Readme
BOLT.EARTH Logger
This is an internal module of BOLT.EARTH for remote logs routing via fluent bit.
Installation
npm i --save @bolt.tech/logger
Initialise Logger
Create a
logger.ts
file and paste below template to initialise your logger.
import * as dotenv from "dotenv";
dotenv.config();
import Logger from "@bolt.tech/logger";
const logger = new Logger(process.env.PARAMSTORE_PATH, process.env.NODE_ENV_LOCAL, tag);
export { logger };
Class Logger
takes three arguments as inputs, paramstorePath
, isLocal
and tag
.
paramstorePath
can be dev
, preprod
or prod
.
If isLocal
is "TRUE"
, then the logger would by default skip all the emit events.
Basic Usage
Class Logger
has public methods specific to certain use cases.
emit
is a general method which is to be used to emit any logs to Fluent-Bit.emit
takes three arguments,label
,event
andbypassLocal
.bypassLocal
is default true. In case you want to print any emit events when running locally, you can set this tofalse
to print logs on your local console.emitRequestLog
is used to emit a specific log to capture response and trace the incoming request.emitDebugLog
is used to emit debug logs. This is to replace the console.log and trace all logs on ES.