Skip to content

Repository files navigation

@nishidhx/logger

A lightweight and developer-friendly logging library for Node.js and TypeScript applications. It provides simple, readable log methods that make debugging, monitoring, and tracking application behavior easier. Distinguish the logs by tags and particular colors.

Support

If you encounter any issues or have feature requests, you can:

Contributions, bug reports, and feedback are always welcome.

Installation

npm

npm install @nishidhx/logger

Yarn

yarn add @nishidhx/logger

Bun

bun add @nishidhx/logger

Preview

Changed the timing from ISO string to formatted time.

logger

Usage

Import the logger into your project:

import { logger } from "@nishidhx/logger";

Log Levels

Method Description
logger.I() Log informational messages.
logger.D() Log debug messages for development and troubleshooting.
logger.W() Log warning messages for non-critical issues.
logger.E() Log error messages when something goes wrong.

Information

logger.I("This is an info log");

Debug

logger.D("This is a debug log");

Warning

logger.W("This is a warning log");

Error

logger.E("This is an error log");

Example Output

[I] This is an info log
[D] This is a debug log
[W] This is a warning log
[E] This is an error log

Date format

By default the library formats timestamps in format.ts using the local time for the clock and an ISO-style date for the day. Concretely the current implementation builds a string like:

[2026-07-03 10:23:45 AM]:[INFO]: Your message here

How to implement a custom transport path

Registering the transport with a Logger (you can create a new Logger instance or pass transports into the exported singleton):

import { ConsoleTransport, FileTransport, Logger } from "@nishidhx/logger";

const customLogger = new Logger({
    transports: [
        new ConsoleTransport(),
        new FileTransport({
            filename: "_app.log",
            timeStampedFilename: true,
            path: "logs"
        })
    ]
})

customLogger.I("Hello")

File Transport has 4 propertis

  • filename : you can change the filename as per your choice.
  • timeStampedFilename : set to true if u wants the logs files gets created based on the time logging started.
  • path : set your own custom path from the saving of logs.
  • append : setting it to true will append all the logs in one file.

Quick test

Run unit tests or local validation (if applicable):

npm test

If you'd like, I can add a small example transport file and a test showing registration and output.

License

MIT © Nishidh Singh

About

A lightweight and developer-friendly logging library for Node.js and TypeScript applications. It provides simple, readable log methods that make debugging, monitoring, and tracking application behavior easier. Distinguish the logs by tags and particular colors.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages