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

loglow

v0.1.0

Published

A flexible logging utility for Node.js, offering customizable color, style, and timestamp options for enhanced console output.

Downloads

11

Readme

Loglow 🌟

Loglow is a flexible logging utility for Node.js, designed to enhance your console output with customizable colors, styles, and timestamps. It's perfect for developers looking for more than just the standard logging capabilities.

Installation

To install Loglow, run the following command in your Node.js project:

npm i loglow --save-dev

Usages

Basic Logging

Loglow enables you to log messages to the console using the add method followed by the print method.

new Loglow().add('Hello, world!').print();
// Output: Hello, world!

Adding Colors and Styles

Loglow allows you to add different colors and styles to your log messages.

new Loglow()
    .add(LogColor.Red, 'Error: Something went wrong.')
    .print();
// Output: Error: Something went wrong. <-- (in red)

Also, Loglow supports multiple colors and styles for a single message.

new Loglow()
    .add(LogColor.Red, LogStyle.Bold, 'Error: Something went wrong.')
    .print();
// Output: Error: Something went wrong. <-- (in bold red)

Adding Timestamps

Loglow can automatically add timestamps to your log messages using the addTimestamp method.

new Loglow()
    .addTimestamp()
    .add('Hello, world!')
    .print();
// Output: 2021-01-01T12:00:00Z Hello, world!

Loglow also allows you tou customize the timestamp color or style.

new Loglow()
    .addTimestamp(LogColor.Cyan)
    .print();
// Output: 2021-01-01T12:00:00Z <-- (in cyan)

Adding New Lines

Loglow provides the addNewLine method to add new lines to your log messages.

new Loglow()
    .add('First line.')
    .addNewLine()
    .add('Second line.')
    .print();
// Output: First line.
//         Second line.

Chaining Methods

Loglow methods can be chained together to create complex log messages.

new Loglow()
    .addTimestamp()
    .add(LogColor.Green, 'Success: Operation completed.')
    .addNewLine()
    .add(LogColor.Blue, LogStyle.Reverse, 'Details: ')
    .addNewline()
    .add('- Item 1')
    .addNewLine()
    .add('- Item 2')
    .print();
// Output: 2021-01-01T12:00:00Z Success: Operation completed. <-- (in green)
//         Details: <-- (in reverse blue)
//         - Item 1
//         - Item 2

Colors and Styles

Loglow provides a set of predefined colors and styles that can be used to customize the output. Here's a list of available colors and styles:

Colors

  • LogColor.Red
  • LogColor.Green
  • LogColor.Yellow
  • LogColor.Blue
  • LogColor.Magenta
  • LogColor.Cyan
  • LogColor.White

Styles

  • LogStyle.Reset - Resets the style to the default
  • LogStyle.Bold - Makes the text bold
  • LogStyle.Dim - Makes the text dim
  • LogStyle.Italic - Makes the text italic
  • LogStyle.Underscore - Underlines the text
  • LogStyle.Blink - Makes the text blink
  • LogStyle.Reverse - Reverses the foreground and background colors

That's it! I hope you find Loglow useful for your Node.js projects!