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

l-print

v0.0.9

Published

Color and format for nodejs console.log

Downloads

38

Readme

l-print

Color and format for nodejs console.log

Nodejs console logger

Library purpose is to format nodejs console to make output more readable.

Examples:

const l = require('l-print')

l(`It's error message`).date().text('ERROR').red().log()
// [22:22:22]<<<<ERROR>>> It's error message
// printed with red font color

2 way to log

Regular logging

const l = require('l-print')

l('here is test string').lvl1().red().date().log()

creating logging patern

const l = require('l-print')

const error = l().pipe('red', 'date', 'log')
error('print this error')

Doc

library function

require('l-print')

l-print is function that return printer object It's accept argument that represents text you want to log

const lPrint = require('l-print')
lPrint('Here is text to log')

color

Coloring console font Supported colors:

  • blue
  • black
  • cyan
  • green
  • magneta
  • red
  • white
  • yellow

usage

l('text').red().log()

bgColor

Coloring console font background Supported colors:

  • blue
  • black
  • cyan
  • green
  • magneta
  • red
  • white
  • yellow

usage to use add 'bg' bedore color and uppercase first letter

l('text').bgBlue().log()

effects

Applying effect on console text Supported effects:

  • bright
  • dim
  • underscore

usage

l('text').underscore().log()

pad

Adding space or characters before logging text.

pad(number, string)
  • number: number of characters to pad at start
  • string: character that will be padded [optional]

usage

l('text').pad(5,'.')
//.....text

lvlx

Similar to pad but with predefined padding value

lvlx(string)
  • string: character that will be padded [optional]

levels:

  • lvl0: no padding
  • lvl1: 4 paddings
  • lvl2: 8 paddings
  • lvl3: 12 paddings
  • lvl4: 16 paddings

usage

l('text').lvl2('>').log()
//########text

date

Console log will be preceded with date in format: [HH:MM:SS]

date()

usage

l('text').date().log()
//[22:22:22] text

text

Add descriptive text before text and padding (but after date)

text(string, array)
  • string: text to display
  • array[optional]: index[0] opening characters, index[1] closing characters by default ['<<<','>>>']

usage

log('text').text('ERROR').log()
//<<<ERROR>>> text
log('text').text('WARNING',['###','###']).log()
//###WARNING### text

pipe

It enable to create other way of logging by predefining pattern as parameters it accepts other l-print function names

usage

const error = l().pipe('date', 'red', 'log')
error('Error message')
//[22:22:22] Error message
// printed with red font

log

Logging to console

log()