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

prism-logger

v1.1.1

Published

beautified logging in nodejs

Downloads

36

Readme

PrismLogger

A simple and colorful logger all types of JavaScript applications.

Installation

You can install PrismLogger using npm:

npm install prism-logger

Usage

The package provides two different Loggers - PrismLogger for NodeJs applications and ConsoleLogger for browser consoles. You may use any one based on your project requirements, but the usage is same for the both of them.

  1. Import the PrismLogger class from prism-logger
import { PrismLogger } from "prism-logger";
  1. Use the varius log functions provided. For instance,
PrismLogger.yellow("This will be printed in yellow");
// The yellow() logs the text in yellow font

NOTE: PrismLogger has static methods so you don't need to create an object but for ConsoleLogger an object has to be created with a boolean parameter named 'debug'. This will determine whether the logs will show up in the console. This will be particulary useful when you need to show some logs in development for dubugging but you don't want them in produnction environment. Setting the debug value to 'false' in production will remove all logs.

Pretty simple, right? Well that's the purpose of this package. There's also a way to make your own custom logger. But let's discuss it later.

First let's dicuss other built-in log functions.

Available Methods

Changing only the text color

| Function | Use | | ---------- | ------------------------------------- | | .error() | Logs an error message in red text | | .success() | Logs a success message in green text | | .warning() | Logs a warning message in yellow text | | .red() | Logs a message in red text | | .green() | Logs a message in green text | | .yellow() | Logs a message in yellow text | | .blue() | Logs a message in blue text | | .magenta() | Logs a message in magenta text | | .cyan() | Logs a message in cyan text | | .white() | Logs a message in white text |

Changing the background color

| Function | Use | | ------------ | --------------------------------------------- | | .errorBg() | Logs an error message with red background | | .successBg() | Logs a success message with green background | | .warningBg() | Logs a warning message with yellow background | | .redBg() | Logs a message with red background | | .greenBg() | Logs a message with green background | | .yellowBg() | Logs a message with yellow background | | .blueBg() | Logs a message with blue background | | .magentaBg() | Logs a message with magenta background | | .cyanBg() | Logs a message with cyan background | | .whiteBg() | Logs a message with white background |

That's all for the built-in functions. The above functions are availabe in both the loggers. Now let's talk about making your own custom logs.

You can use the .logBg() to create a custom log.

PrismLogger.logBg("Your message", "blue", "white");
// This will create a log with white background and blue text

You can use any of the following colors:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray

Examples

import { PrismLogger, ConsoleLogger } from "prism-logger";

const logger = new ConsoleLogger((debug = true)); // the boolean variable debug determines whether the logger will log anything

logger.log("Hello, world!", "cyan");
logger.error("Something went wrong");
logger.success("Task completed successfully");
logger.warning("Be cautious!");

logger.logBg("This is a log with custom colors", "white", "blue");
logger.errorBg("This is an error with red background");