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

logdc

v2.0.2

Published

Simple console log for NodeJs with colors and timestamp

Downloads

35

Readme

logdc

Simple console log for NodeJs with colors and timestamp. 0 dependencies.

Logdc example

Installation

$ npm install logdc
$ yarn add logdc

Usage

const log = require(logdc);

log.info('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem');
$[19:15:46] INFO    : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'

Types (Default)

// code
log.info('Lorem Ipsum');
log.warn('Lorem Ipsum');
log.error('Lorem Ipsum');
log.success('Lorem Ipsum');
log.log('Lorem Ipsum');
log.br();
// console:

$[19:15:46] INFO    : 'Lorem Ipsum'
$[19:15:46] WARN    : 'Lorem Ipsum'
$[19:15:46] ERROR   : 'Lorem Ipsum'
$[19:15:46] SUCCESS : 'Lorem Ipsum'
$[19:15:46] LOG     : 'Lorem Ipsum'
$[19:15:46] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 

Separator

log.br();
$[19:15:46] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::

To change separator character override default settings for label br.

Settings

Override default settings or create new labels in your package.json file.

Add logdcConfig node:

  "logdcConfig": {
    "labels": {
      "foo": {
        "color": "red",
        "text": "My Custom label"
      },
      "warn": {
        "color": "green",
        "text": "Do not warn me!"
      }
    },
    "time": true,
    "counter": 2,
    "equal": true
  }

1. Labels

1.1. Hide labels

  "logdcConfig": {
    "labels": false
  }
log.info('Lorem Ipsum');

$[19:19:25] 'Lorem Ipsum'

1.2. Add custom labels, or override default

"logdcConfig": {
    "labels": {
        "foo": {
            "color": "red",
            "text": "My Custom label"
        },
        "warn": {
            "color": "green",
            "text": "Do not warn me!"
        }
    }
}
log.foo('Lorem Ipsum');
$[19:15:46] FOO     : 'Lorem Ipsum'

log.warn('Lorem Ipsum');
$[19:15:46] DO NOT WARN ME! : 'Lorem Ipsum'

1.3. Equal length

Length of labels (type name + spaces + ':') is equal to longest type name (default 8 SUCCESS :), so that colon is always at the same vertical position. To disable this behaviour set equal as false

"logdcConfig": {
    "equal": false
}
log.info('Lorem Ipsum');
log.error('Lorem Ipsum');
// console
$[19:15:46] INFO: 'Lorem Ipsum'
$[19:15:46] ERROR: 'Lorem Ipsum'

2. Time

To hide timestamp set time to false

"logdcConfig": {
    "time": false
}
log.info('Lorem Ipsum');
$INFO    : 'Lorem Ipsum'

3. Colors

Label name has color.

Config counter is defining number of logged arguments to colorize, default is 2, or colorize label and first argument.

3.1. To disable colors pass set counter as 0

"logdcConfig": {
    "counter": 0
}
log.info('Lorem Ipsum');
$[19:15:46] INFO    : 'Lorem Ipsum'

3.2. To add colors to other logged parameters increase counter (1 is for label)

"logdcConfig": {
    "counter": 4
}
log.info('Lorem Ipsum', {foo: 'bar'}, 'Third param');
$[19:15:46] INFO    : 'Lorem Ipsum', { foo: 'bar' }, 'Third param'

3.3. To change color of default label set labels with default type as key:

"logdcConfig": {
    "labels": {
        "error": {
            "color": "white",
            "text": "No errors"
        },
        "warn": {
            "color": "green",
            "text": "Do not warn me!"
        }
    }
}
log.error('Lorem Ipsum');
$[19:15:46] NO ERRORS : 'Lorem Ipsum'

Default arguments

  "logdcConfig": {
    "labels": {
        "log": {
            "color": "white",
            "text": "log"
        },
        "info":    {
            "color": "white",
            "text": "info"
        },
        "warn":    {
            "color": "yellow",
            "text": "warning"
        },
        "error":   {
            "color": "red",
            "text": "error"
        },
        "success": {
            "color": "green",
            "text": "success"
        },
        "br":      {
            "color: "white",
            "text": ":"
        }
    },
    "time": true,
    "counter": 2,
    "equal": true
  }

Examples

Logdc examples

log.info('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem')
$[17:03:26] INFO    : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'
log.warn('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem')
$[17:03:26] WARN    : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'
log.error('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem')
$[17:03:26] ERROR   : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'
log.success('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem')
$[17:03:26] SUCCESS : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'
log.log('Lorem Ipsum', {foo: ['bar']}, [1, 2, 3], 'Dolorem')
$[17:03:26] LOG     : 'Lorem Ipsum', { foo: [ 'bar' ] }, [ 1, 2, 3 ], 'Dolorem'
log.br()
$[17:03:26] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::