@northnerds/custom-logger
v1.0.5
Published
A custom logger for microservices
Readme
@northnerds/custom-logger
A lightweight, customizable logging utility for microservices built by the NorthNerds team.
Installation
Install the package via npm:
npm install @northnerds/custom-loggerUsage
Import the logger into your TypeScript or JavaScript project and configure it with a log file path. Use the static methods info, warn, and error to log messages with optional metadata.
Example
import Logger from "@northnerds/custom-logger";
// Configure the log file path (optional, defaults to "/app/logs/app.log") Logger.configure({ logFilePath: "./logs/service.log" });
// Log messages with optional metadata Logger.info("Service started", { serviceId: "chat-123" }); Logger.warn("Resource usage high", { memory: "80%" }); Logger.error("Database connection failed", { error: "timeout" });
Output
Logs are written to both the console and the configured log file in the following format: [2025-03-19TXX:XX:XX.XXXZ] [INFO] Service started {"serviceId":"chat-123"} [2025-03-19TXX:XX:XX.XXXZ] [WARN] Resource usage high {"memory":"80%"} [2025-03-19TXX:XX:XX.XXXZ] [ERROR] Database connection failed {"error":"timeout"}
