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

log-beautify

v1.2.0

Published

Show log messages on your terminal with style :-) . Use debugging levels to enable or disable log messages.

Downloads

3,877

Readme

log-beautify

Show log messages on your terminal with style :-) . Use debugging levels to enable or disable log messages.

Installation

npm install log-beautify

Usage

const log = require('log-beautify');

log.trace('Trace');//change the level to use trace
log.success('Success');
log.ok('Ok');//success alias
log.debug('Debug');
log.info('Info');
log.warning('Warning');
log.warn('Warn');//warning alias
log.error('Error');

Use case :-)

API

Log methods

  • log.success() (for text color)
  • log.success_() (for background color)
  • log.ok() (log.success() alias)
  • log.ok_() (log.success_() alias)
  • log.debug()
  • log.debug_()
  • log.info()
  • log.info_()
  • log.warning()
  • log.warning_()
  • log.warn() (log.warning() alias)
  • log.warn_() (log.warning_() alias)
  • log.error()
  • log.error_()
  • log.show()(default console.log())

You can create your own log methods, for example:

log.setColors({
    custom_: "green",
});
log.setSymbols({
    custom_: "✅ ",
});


//Now you can use it
log.custom_('Server listening on port 3000 ');

Log levels

Global level is: 1 Default level for new log methods: 1 Default levels:

{
    silent: -1,//hide all logs
    trace: 0,
    success: 1,
    debug: 2,
    info: 3,
    warning: 4,
    error: 5,
}

Config

  • log.useSymbols = true (Enable or disable symbols)
  • log.useLabels = true (Enable or disable labels)
  • log.setColors({}) (Add or change colors)
  • log.setSymbols({}) (Add or change symbols)
  • log.setLabels({}) (Add or change labels)
  • log.setTextColors({}) (Change text colors for bg logs)
  • log.setLevel(1) (Change global level, default = 1)
  • log.setLevel(1, 'namespace') (log.setNamespaceLevel() alias)
  • log.setNamespaceLevel(1, 'namespace') (Create level with namespace and use it in current file, The global level will be ignored)
  • log.namespace('namespace') (log.useNamespace() alias)
  • log.useNamespace('namespace') (Use the level of a namespace in the current file, The global level will be ignored. You can use namespaces created in other files)
  • log.setLocalLevel(1) (Create a level to use only in the current file, The global level will be ignored)
  • log.setLevels({}) (Add or change levels)

Colors

You can use the following color formats. (Use strings)

  • keyword Example: "red" (black,white,red,green,yellow,magenta,cyan,gray)
  • hex Example: "#FFF000"
  • rgb Example: "rgb(255, 255, 255)"
  • hsl Example: "hsl(0, 100%, 50%)"
  • hsv Example: "hsv(330, 93%, 98%)"
  • hwb Example: "hwb(0, 100%, 0%)"

Usage examples


/**
|--------------------------------------------------
| Disable symbols
|--------------------------------------------------
*/
log.useSymbols = false;


/**
|--------------------------------------------------
| Disable labels
|--------------------------------------------------
*/
log.useLabels = false;


/**
|--------------------------------------------------
| Change colors
|--------------------------------------------------
*/
log.setColors({
    success: "#00FF00",
    error_: "rgb(191,0,96)",
    info_: "cyan",
});


/**
|--------------------------------------------------
| Add or change new log methods
|--------------------------------------------------
*/
//When you add a color, the method will automatically be created.
log.setColors({
    danger: "#FF8000",
    danger_: "hsl(310, 99%, 57%)",
    saved: 'green',
});
//Now you can use log.danger() and log.danger_() and log.saved()


/**
|--------------------------------------------------
| Add or change symbols
|--------------------------------------------------
*/
log.setSymbols({
    danger: "⛔ ",
    ok: "👍 ",
    saved: "✅ "
});


/**
|--------------------------------------------------
| Add or change labels
|--------------------------------------------------
*/
log.setLabels({
    warning: "WARNING!!!",
});


/**
|--------------------------------------------------
| Add or change text colors for bg logs
|--------------------------------------------------
*/
log.setTextColors({
    error_: 'black',
    info_: 'black',
});


/**
|--------------------------------------------------
| Add or change levels
|--------------------------------------------------
*/
log.setLevels({
    fatal: 6,
    custom: "info"//use info level
});


/**
|--------------------------------------------------
| Change global level. 2 = "debug"
|--------------------------------------------------
*/
log.setLevel(2);
//log.setLevel('debug');


/**
|--------------------------------------------------
| Add level "info = 3" to use only in the current file, The global level will be ignored
|--------------------------------------------------
*/
log.setLocalLevel('info');


/**
|--------------------------------------------------
| Create level with namespace and use it in current file, The global level will be ignored
|--------------------------------------------------
*/
log.setNamespaceLevel('error', 'show-only-errors');


/**
|--------------------------------------------------
| Use namespace created previously. You can use namespaces created in other files.
|--------------------------------------------------
*/
log.useNamespace('show-only-errors');
//log.namespace('show-only-errors');

Collaborators

Thanks

License

MIT