Logging Chiper
Table of Contents
Description
This simple module offers a way to use some functionalities from the
logging-chiper.
Motivation
As company we want to standardize the way we log our application, so that's we
wrote this module to make it easier to log our application.
Requirements
- Nodejs LTS.
- GOOGLE_APPLICATION_CREDENTIALS defined with the file path as environment
variable.
Usage
Install
npm i logging-chiper -S -E
OR
yarn add logging-chiper -S -E
Parameters
As we want to standardize the way we log our application, so we defined a base
structure as input parameters to accomplish this:
Logger.log({
stt: "my-stt",
context: "my-context",
functionName: "my-function",
message: "my-message",
data: {
storeId: "" + 123456,
responseCode: "" + 200,
testField: "test",
extraField: "extra",
},
});
Logger.warn({
stt: "my-stt",
context: "my-context",
functionName: "my-function",
message: "my-message",
data: {
storeId: "" + 123456,
responseCode: "" + 200,
testField: "test",
extraField: "extra",
},
});
Logger.warn({
stt: "my-stt",
context: "my-context",
functionName: "my-function",
message: "my-message",
error,
data: {
storeId: "" + 123456,
responseCode: "" + 200,
testField: "test",
extraField: "extra",
},
});
As you can see, all the methods follows almost the same structure, but when you
want to log an error, you need to pass the error as parameter.
Example
import { Logger } from 'logging-chiper';
const bootstrap = () => {
Logger.log({
stt: 'solutions',
context: 'main.ts',
functionName: 'bootstrap',
message: 'this is a log message...',
});
};
}
bootstrap();