0.0.5 • Published 10 months ago
@lucas-pmelo/logger v0.0.5
Logger Usage Guide
Overview
This guide provides a step-by-step explanation of how to use the Lucas Melo Logger library. Each section describes a specific functionality along with code examples.
Installation
Install the logger library using npm:
npm install @lucas-pmelo/logger
Usage
Resetting Log Configurations
To reset the logger's configurations:
logger.reset();
Setting Log Level
To set the log level, available options are: "trace"
, "debug"
, "info"
, "warn"
, and "error"
. The default level is "trace"
.
logger.setLevel("debug");
Setting Service Name
To set the service name:
logger.setService("self-service");
Setting Request ID
To set the request ID:
logger.setRequestId("123");
Setting HTTP Request
To set HTTP request details:
logger.setHttp("POST", "http://localhost:400", "localhost");
Setting User Information
To set user information:
logger.setUser("id", "email");
Retrieving Logger Configurations
To get the current logger configuration:
logger.getConfig();
Logging Messages
Trace Log:
logger.trace({ message: "trace log", });
Debug Log:
logger.debug({ message: "debug log", });
Info Log:
logger.info({ message: "info log", });
Warn Log:
logger.warn({ message: "warn log", });
Error Log:
logger.error({ message: "error log", });