2.0.0 ā€¢ Published 1 year ago

logzy v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Features

  • Zero dependencies!
  • Ultralight! ~1.5kb min
  • Flexible and user friendly API
  • Supports Object debugging
  • Provides utils for advanced nesting
  • Adds life to the console.log
  • Ridiculously easy to use
  • Really fast

Installation

npm i -D logzy

API

log()

Custom function for stylizing console messages.

/**
 * Custom function for stylizing console messages.
 *
 * @param keys Array of strings, accepts one or more values.
 * @param message Custom message, can be anything.
 * @param [debug] Enables debug mode for objects (optional).
 */
log(keys, message, debug)
// Examples

import { log } from 'logzy'

// Outputs a stylized message
log(['cyan'], 'custom message...')
log(['lime', 'bold', 'underline'], 33 * 77)
log(['black', 'bold', 'bg_white'], message)

// Outputs a stylized `console` object
log(['cyan', 'italic'], console, 'inspect')

// Outputs a stylized object in `json` format
log(['sky', 'italic', 'bold'], { a: 'b', c: 'd', e: 'f' }, 'json')

Nesting & Customization

Logzy comes with a built-in tiny utilities designed for nesting and raw customization.

These utils must be wrapped with console.log to actually output the styled message.

/**
 * Tiny utility function designed for nesting and raw customization.
 * Basically the same as the main `log()` function but without `console.log` wrapper.
 *
 * @param keys Array of strings, accepts one or more values.
 * @param message Custom message, can be anything.
 * @param [debug] Enables debug mode for objects (optional).
 */
log.$(keys, message, debug)
// Examples

import { log } from 'logzy'

console.log(log.$(['cyan', 'bold'], 'logzy is fire'))
// Examples

import { log, cl } from 'logzy'

const { $, bold, cyan, reset } = log

cl($(['cyan', 'bold', 'underline'], 'logzy is fire'))

cl(`${$(['lime', 'bold'], 'logzy')} is ${$(['rose', 'italic'], 'fire')}`)

cl(`${bold}${cyan}custom message...${reset}`)

Debugging

Also, Logzy supports object outputs with a node's inspect utility and native JSON.stringify method under the hood.

By default, debug mode is disabled.

// Examples

import { log } from 'logzy'

// enables node's inspect utility
log(['cyan', 'italic'], console, 'inspect')

const obj = {
  a: 'logzy',
  b: {
    c: {
      d: [1, 2, 3]
    },
    e: {
      f: true
    }
  }
}

// enables JSON.stringify method
log(['lime', 'bold'], obj, 'json')

Keys

List of all available keys

Text ColorsBackground ColorsText Styles
amberbg_amberbold
blackbg_blackcrossout
bluebg_bluedarken
cyanbg_cyanhidden
graybg_grayinvert
greenbg_greenitalic
indigobg_indigoreset
limebg_limeunderline
magentabg_magenta
pinkbg_pink
redbg_red
rosebg_rose
silverbg_silver
skybg_sky
whitebg_white
yellowbg_yellow

Show Support

This is a free and open source project available to everyone. If you like it, leave a star to show your support.

Starring a repository

Navigate to the top-right corner of the page and click the ā˜† Star button.

License

logzy

MIT License

Copyright Ā© Ivo Dolenc

Developed in Croatia šŸ‡­šŸ‡·

1.0.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

2.0.0

1 year ago

0.1.0

2 years ago

0.0.1

2 years ago