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

nyx-logger

v3.0.0

Published

nyx-logger is a simple logger for Node.js, designed to facilitate the logging of console messages with severity levels such as information, warning and error. This module uses colors to make log messages more legible and includes timestamps for easy track

Downloads

1,044

Readme

nyx-logger

Nyx Logger is a simple logger for Node.js, designed to facilitate the logging of console messages with severity levels such as information, warning and error. This module uses colors to make log messages more legible and includes timestamps for easy tracking of events.

Features

  • Log levels: Log messages with different levels of severity (info, warning, error).
  • Colors: Use colors to distinguish log levels in the console.
  • Timestamp: Each log message is preceded by a timestamp for easy tracking.

Installation

To install Nyx Logger, use npm (Node Package Manager). Run the following command in your terminal:

Copy the code npm install nyx-logger How to use Here's how to use Nyx Logger in your project:

// Import the module
const { log, logfile } = require('nyx-logger');

//Set file path
logfile.set_log_file("../your/path/log.txt");

// Log an information message
log(“info”, 'This is an information message.');

// Log a sucess message
log(“done”, 'This is a sucess message.');

// Log a warning message
log(“warn”, 'This is a warning message.');

// Log an error message
log(“err”, 'This is an error message.');

// Log a developer message
log(“dev”, 'This is a developer message.');

Custom Log:

Customizable Tag:

  • Each log is associated with a tag (e.g., [INFO], [ERROR], [DEBUG]), indicating the type of message.
  • The tag text can be colored for better readability.
  • Option to color only the text within the tag, or the brackets around it as well.

Flexible Coloring:

  • tagColor: Defines the color of the tag text (e.g., red, green, blue).
  • colorBrackets: Controls whether the brackets [ ] around the tag should be colored or not. If true, the entire tag [INFO] is colored. If false, only the word inside the tag is - colored, leaving the brackets neutral.

Timestamp Management:

  • Logs can include a timestamp to show the exact date and time the log was generated.
  • Customization options:
  • Display the time, date, or both.
  • Timestamp format follows HH:mm:ss:SSS YYYY-MM-DD.

Elapsed Time Between Logs:

  • Option to display the elapsed time between consecutive logs.
  • Useful for performance monitoring and analyzing delays.

Log File Storage:

Each log is not only printed to the console but also saved to a text file for long-term tracking and review.

Available Parameters:

  • tag: The name of the tag displayed with the log (default: 'LOG').
  • message: The log message text.
  • tagColor: The color of the text inside the tag (e.g., red, green, blue, etc.).
  • colorBrackets: A boolean (true/false) that specifies whether the brackets [ ] around the tag should be colored.
  • includeTimestamp: Whether or not to include a timestamp in the log.
  • includeDate: Whether to include the date in the timestamp.
  • includeTime: Whether to include the time in the timestamp.
  • showElapsedTime: Whether to display the elapsed time between logs.
  • lastLogTime: Used to calculate the elapsed time between logs (pass this value from a previous log for accurate timing).

Examples

customLog('INFO', 'System startup...', 'green', true, true, true, true);

or

customLog({
    tag: 'INFO',
    message: 'System startup...',
    tagColor: 'green',
    colorBrackets: true,
    includeTimestamp: true,
    includeDate: true,
    includeTime: true
});

Contributions

Contributions are welcome! If you'd like to improve the module, don't hesitate to submit a pull request.

License This project is licensed under the MIT license. See the LICENSE file for more information.