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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ajayos/nodelogger

v1.0.9

Published

This is a logging module that allows the user to log messages with different severity levels. The module uses the Winston logging library and allows the user to configure various options for the log files.

Downloads

36

Readme

nodelogger

@ajayos/nodelogger is a Node.js module for logging messages with customizable severity levels and output formats.

@ajayos/nodelogger

Installation

To install @ajayos/nodelogger, run:

npm install @ajayos/nodelogger

Usage

First, import the module into your Node.js application:

const { default: Logger } = require("@ajayos/nodelogger");

Then, create an instance of the Logger class with the desired configuration options and start it:

const options = {
  timeZone: "Asia/Kolkata",
  hour: "numeric",
  minute: "numeric",
  hour12: true,
  filename: "logs/%DATE%.log",
  datePattern: "YYYY-MM/DD",
  zippedArchive: false,
  maxSize: "1g",
  level: "info",
};

const logger = new Logger(options);

Once the logger is started, you can log messages with the log method:

logger.line();
logger.error("This is an error message");
logger.warn("This is a warning message");
logger.info("This is an info message");
logger.debug("This is a debug message");
logger.error("err");
logger.line();

LOG

You can also log messages with the default severity level by omitting the second argument:

logger.log("This is a default message");

To log a horizontal line, use:

logger.line();

To clear screen:

logger.clear();

Example

Additional example of how to use the package can be found in the example file.

Configuration Options

The following configuration options are available for the logger:

  • timeZone (string): The timezone to use for the log file (default: 'Asia/Kolkata')
  • hour (string): The hour format to use for the log file (default: 'numeric')
  • minute (string): The minute format to use for the log file (default: 'numeric')
  • hour12 (boolean): Whether to use 12-hour format or not. 1 for true, 0 for false (default: false)
  • filename (string): The file path with %DATE% as a placeholder for the date (default: 'logs/%DATE%.log')
  • datePattern (string): The date pattern for the filename (default: 'YYYY-MM/DD')
  • zippedArchive (boolean): Whether to zip the archived files or not (default: false)
  • maxSize (string): The maximum size of each log file before rotation (default: '1g')
  • level (string): The level of the log messages (default: 'info')

Only console log

Use logger.logs("This is a message") also logger.logs("This is a message", message type)

Message Types

The following message types are available for the log method:

  • info (or i): Informational message (green text)
  • warn (or w): Warning message (yellow text)
  • error (or e): Error message (red text)
  • debug (or d): Debug message (magenta text)
  • fatal (or f): Fatal message (white text on red background)
  • line (or l): Horizontal line (cyan text)

Output Format

The output format for each message type is as follows:

  • Informational message (green text): [timestamp] [*]> message
  • Warning message (yellow text): [timestamp] [!]> message
  • Error message (red text): [timestamp] [x]> message
  • Debug message (magenta text): [timestamp] [*]> message
  • Fatal message (white text on red background): [timestamp] [!]> message
  • Horizontal line (cyan text): >-----------------------------<

License

@ajayos/nodelogger is released under the Apache-2.0 License.