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

lowkey-console

v1.1.2

Published

Lowcon (as known as lowkey-console) is a minimalist, highly customizable logging utility for Node.js that enhances your console output with styled, colorful messages. It features animated loading indicators, progress bars, customizable log prefixes, and s

Downloads

91

Readme

Lowcon

NPM Version NPM Downloads License

Lowcon (also known as lowkey-console) is a minimalist, highly customizable logging utility for Node.js that enhances your console output with styled, colorful messages. It features animated loading indicators, progress bars, customizable log prefixes, and supports various logging levels. All while leveraging external libraries like ora and cli-progress.

Support

Features

  • 🎨 Customizable Colors: Define and personalize log colors using ANSI escape codes for better visual clarity.
  • ⚠️ Built-in Log Types: Convenient methods for warnings, errors, debug, success, and info logs.
  • Animated Loading Symbols: Add dynamic loading indicators with a range of symbols.
  • 📊 Progress Bars: Create interactive progress bars to track tasks or download progress.
  • 🖋 Customizable Prefixes: Effortlessly add and tweak prefix characters for each log type.
  • 🎯 External Dependency Support: Integrated with ora for loading indicators and cli-progress for progress bars.

Preview

Here’s a preview of Lowcon in action:

Lowcon Preview

Installation

Install Lowcon via npm:

npm install lowkey-console

Usage

Here’s an example of how to use Lowcon in your Node.js project:

import lowcon from 'lowkey-console'

// Simulate warn, error, success, info and debug state.

lowcon.warn('This is a warning.', { useBrackets: false, keepColoring: false, prefixChar: '»  ' });
lowcon.error('This is an error.', { useBrackets: false, keepColoring: false, prefixChar: '»  ' });
lowcon.success('This is a success.', { useBrackets: false, keepColoring: false, prefixChar: '»  ' });
lowcon.info('This is an info.', { useBrackets: false, keepColoring: false, prefixChar: '»  ' });
lowcon.debug('This is a debug.', { useBrackets: false, keepColoring: false, prefixChar: '»  ' });

Log Methods

  • warn(message, options): Logs a warning message.
  • error(message, options): Logs an error message.
  • success(message, options): Logs a success message.
  • info(message, options): Logs an informational message.
  • debug(message, options): Logs a debug message.

Animated Loading

Create dynamic loading indicators:

// Simulate a loading state.

const loadingSession = lowcon.loading('This is a loading message...',
    {
        useBrackets: false,
        keepColoring: false,
        prefixChar: '» ',
        onSuccess: (data) => `This is a successfully loaded message with status : ${data.code}`,
    })

setTimeout(() => loadingSession.success({ code: 204 }), 5000);

Progress Bar

Track the progress of an ongoing task:

let progressValue = 0;

const progressSession = lowcon.progress('Downloading...', progressValue, {
    useBrackets: false,
    keepColoring: false,
    barWidth: 10,
    prefixChar: '»  ',
    onSuccess: (data) => `This is a successful progress message with status : ${data.code}`,
    onFail: (data) => `This is an failed progress message with status : ${data.code}`
});

const timer = setInterval(function () {
    progressValue++
    progressSession.update(progressValue)

    if (progressValue >= 100) {
        clearInterval(timer);
        progressSession.succeed({ code: 200 });
    }
}, 100);

Customization

You can easily modify log colors, symbols, and other settings with setConfig():

import { setConfig, ansiColors } = require('lowkey-console');

setConfig({
    symbols: {
        warning: '⚠',
        error: '✘',
        success: '✔',
        info: 'i',
        debug: '✇',
        loading: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
        progress: {
            loaded: '█',
            unloaded: '▒'
        }
    },
    colors: {
        warning: ansiColors.yellow,
        error: ansiColors.red,
        success: ansiColors.green,
        debug: ansiColors.magenta,
        info: ansiColors.blue,
        loading: ansiColors.cyan,
        progress: ansiColors.whiteBright
    }
});

Configuration Options

  • symbols: Customize the symbols for different log types (warning, error, success, etc.).
  • colors: Define the colors for logs, loading animations, and progress bars.
  • useBrackets: Choose whether to wrap symbols with brackets (default: true).
  • prefixChar: Set custom prefix characters for logs.
  • keepColoring: Retain colors throughout the entire message (default: false).
  • interval: Set the speed for the loading animation (default: 100ms).
  • onSuccess / onFail: Set custom messages or callback functions to execute after loading or progress completion.

Methods

  • warn(message, options): Logs a warning message.
  • error(message, options): Logs an error message.
  • success(message, options): Logs a success message.
  • info(message, options): Logs an informational message.
  • debug(message, options): Logs a debug message.
  • loading(message, options): Starts an animated loading indicator.
  • progress(message, percentage, options): Displays a progress bar.

Contributions

We welcome contributions! If you have suggestions, bug reports, or feature requests, feel free to open an issue or submit a pull request.

Local Development

To develop or modify Lowcon locally:

  1. Clone the repository:
    git clone https://github.com/OptiFiire/lowcon.git
  2. Navigate to the project directory:
    cd lowcon
  3. Install dependencies:
    npm install
  4. Run your tests and start making contributions!