npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dilogger

v0.2.0

Published

A simple file based logging utility for Node.js

Readme

Dilogger

A lightweight, customizable logging utility for Node.js applications. This package provides a simple and flexible way to log messages to a file with timestamps, caller information, and support for multiple log levels (INFO, DEBUG, WARNING, ERROR). It also supports custom time zones for log timestamps.


Features

  • File Logging: Log messages to a file with automatic directory creation.
  • Log Levels: Supports INFO, DEBUG, WARNING, and ERROR log levels.
  • Custom Time Zones: Specify a time zone for log timestamps.
  • Caller Information: Automatically includes the caller function name in logs.
  • Flexible Configuration: Customize log file names, paths, and backup paths.

Installation

Install the package using npm:

npm install dilogger

Usage

Basic Example

import { createLogger } from "dilogger";

// Create a logger instance
const logger = createLogger({
    FILE_NAME: "app.log",
    TIMEZONE: "America/New_York",
});

// Log messages
logger.info("This is an info message.");
logger.debug("This is a debug message.");
logger.warning("This is a warning message.");
logger.error("This is an error message.");

Output in app.log

[10/15/2023, 3:45:12 PM] - (main) - [INFO] - This is an info message.
[10/15/2023, 3:45:12 PM] - (main) - [DEBUG] - This is a debug message.
[10/15/2023, 3:45:12 PM] - (main) - [WARNING] - This is a warning message.
[10/15/2023, 3:45:12 PM] - (main) - [ERROR] - This is an error message.

API Documentation

createLogger(options)

Creates a new logger instance.

Parameters

  • options (Object, optional): Configuration options for the logger.
    • FILE_NAME (String, optional): Name of the log file. Default: "index.log".
    • LOG_MOD (String, optional): Log level. Must be one of "INFO", "DEBUG", "WARNING", or "ERROR". Default: "DEBUG".
    • FILE_PATH (String, optional): Directory for log files. Default: "./logs/".
    • BACKUP_FILE_PATH (String, optional): Directory for backup log files. Default: "./logs/backup/".
    • TIMEZONE (String, optional): Time zone for log timestamps. Default: "UTC".

Returns

  • A LOGGER instance.

LOGGER Class

Methods

  • info(message)

    • Logs an INFO level message.
    • Example: logger.info("This is an info message.");
  • debug(message)

    • Logs a DEBUG level message (only if LOG_MOD is set to "DEBUG").
    • Example: logger.debug("This is a debug message.");
  • warning(message)

    • Logs a WARNING level message.
    • Example: logger.warning("This is a warning message.");
  • error(message)

    • Logs an ERROR level message.
    • Example: logger.error("This is an error message.");

Configuration

Log Levels

The following log levels are supported:

  • INFO: General information.
  • DEBUG: Debugging information (only logged if LOG_MOD is set to "DEBUG").
  • WARNING: Warnings that may require attention.
  • ERROR: Errors that need immediate attention.

Time Zones

You can specify a custom time zone for log timestamps using IANA time zone identifiers (e.g., "America/New_York", "UTC"). For a full list of valid time zones, refer to the IANA Time Zone Database.


Example

Advanced Configuration

import { createLogger } from "dilogger";

// Create a logger with custom settings
const logger = createLogger({
    FILE_NAME: "app.log",
    TIMEZONE: "Asia/Karachi",
    LOG_MOD: "INFO",
    FILE_PATH: "./custom-logs/",
    BACKUP_FILE_PATH: "./custom-logs/backup/",
});

// Log messages
logger.info("Application started.");
logger.debug("This debug message will not be logged because LOG_MOD is INFO.");
logger.warning("Low disk space.");
logger.error("Failed to connect to the database.");

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Support

If you encounter any issues or have questions, please open an issue on the GitHub repository.


Enjoy logging with dilogger! 🚀