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

@halibal/colorful-log

v0.0.5

Published

A simple and customizable colorful console logger for Node.js applications written in TypeScript. This package allows you to log message with different colors and formatting options such as bold and underline.

Downloads

166

Readme

Colorful Log Package

A simple and customizable colorful console logger for Node.js applications written in TypeScript. This package allows you to log message with different colors and formatting options such as bold and underline.

Changelog

Update 0.0.3

  • Now you can colorfulLog the FormData types, too.
  • functions and symbols converted to strings.
  • undefined and null values are explicitly converted to string.
  • special objects:
    • Blob is handled.
  • added basic test scenarios

Update 0.0.4

  • Improved separation of production and test builds.
  • Added separate output directories for test files.
  • Updated how the colorfulLog function receives parameters. It now accepts an object with color, message, and options for clearer usage.
    • Default color value is set to be blue, passing it is optional.
    • message is required and can be a single message or an array of messages.
    • Default options value is set to be an empty array, passing it is optional.

Installation

You can install this package using npm or pnpm:

npm:

npm install @halibal/colorful-log

pnpm:

pnpm add @halibal/colorful-log

Running Tests

To run the test build and execute the tests:

pnpm test

This will generate test files in the dist/tests/ directory and run them.

Build and Production

To build the package for production:

pnpm build

For test builds:

pnpm build:test

This separates production files into the dist/ folder and test files into the dist/tests/ folder.

Usage

The colorfulLog function accepts both a single message or an array of messages, providing flexibility for different logging needs.

The colorfulLog function now accepts an object with color, message, and options parameters:

  • color: (optional) Defaults to blue if not specified.
  • options: (optional) Defaults to an empty array, allowing for additional formatting like bold or underline.

TypeScript:

import { colorfulLog } from 'colorful-log';

const nestedObject = {
    status: 'ok',
    details: {
        user: 'john',
        roles: ['admin', 'user'],
        metadata: {
            lastLogin: new Date(),
            preferences: {
                theme: 'dark',
                notifications: true
            }
        }
    }
};

colorfulLog({
    message: 'Logging a simple message'
});

colorfulLog({
    color: 'green',
    message: ['Operation successful:', { status: 'ok' }]
});

colorfulLog({
    message: ['Operation successful:', nestedObject],
    options: ['underline']
});

colorfulLog({
    color: 'red',
    message: [
        'Error occurred:',
        { message: 'Something went wrong', code: 500 }
    ],
    options: ['bold']
});

colorfulLog({
    message: [
        'This is an default blue message with bold and underline formatting'
    ],
    options: ['bold', 'underline']
});

colorfulLog({
    color: 'purple',
    message: ['This is a regular message with no extra formatting']
});

Parameters:

  • color: (optional) The color of the log, such as 'green', 'red', etc. Defaults to 'blue' if not provided
  • message: (required) Accepts either a single message (string, object, etc.) or an array of messages.
  • options: (optional) Defaults to an empty array. Can include 'bold', 'underline', etc.

Available Colors

The following colors are available for logging:

  • Black
  • Red
  • Green
  • Yellow
  • Blue
  • Purple
  • White

Formatting Options

In addition to colors, you can also add formatting options:

  • Bold
  • Underlined
  • Bold & Underlined

License

This project is licensed under the MIT License.

Contributing

We welcome contributions! Please fork the repository, create a branch, and submit a pull request with your improvements.