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

hot-console

v1.0.0

Published

Console logging with colors and more details

Downloads

5

Readme

Hot Console

Hot Console is a console log replacer for node that includes colors and shows more detailed results. Such as data types, string lengths, and displays arrays and objects in a more readable format.

It's fast and very easy to use!

Screenshot

var log = require('hot-console')

log('Hello World!') // Use instead of console.log
log(34, { color: 'red', background: 'black' })

log([1, 2, [[4, 5], 'nr 3']], { color: 'yellow' })

log('The %s is %d\n', 'time', Date.now(), { color: 'green' })

Installation

$ npm install hot-console

Examples

var log = require('hot-console')

log.setColor('yellow')
  .setBackground('red')
  .setStyle('bold')

log('This text has yellow color, red background and is in bold')
log('This too but has blue backgound', { background: 'blue' })
log('This has changed alot', { color: 'green', background: 'yellow', style: 'italic' })

// Clear all styles
log.clear()

// Quick functions for just red and green text
log.error('Red text')
  .success('Green text')

// Different argument examples
var d = new Date()
log('Today is: %d-%d-%d', d.getFullYear(), d.getMonth(), d.getDate())
log('The', 'weekday', 'is', d.getDay(), { color: 'yellow' })
log('The hour is: %d and the minute is:', d.getHours(), d.getMinutes())

Extra! Console loading animation

var timeout = log.startLoading('loading', { color: 'yellow' })

// loading...

setTimeout(function () {
  log.clear(timeout)
    .success('Finished loading!')
}, 2000)

Functions

Log

log(s, ...arguments, style) // The console log function
  • s: The string/object to console log (can be any datatype).
  • ...arguments: When s is a string any amount of arguments can be added in "printf style", or just added to the end (uses util.format).
  • style: Style object with 3 valid properties (color, background, style) which has to be the last argument (available colors are listed below).

SetColor, setBackground, setStyle and clear

log.setColor(s) // Sets color to use
  .setBackground(s) // Sets background color to use
  .setStyle(s) // Sets style to use

  .clear() // Clears all styles
  • s: String of which color to use in the console.
  • Colors: "red", "black", "green", "yellow", "blue", "magenta", "cyan", "white" or "grey" (grey doesn't work for background color). Null to reset.
  • Styles: "italic", "bold", "underline", "reset", "dim", "inverse", "hidden", "strikethrough". Null to reset.
  • Colors and styles are based on the Colors package (safe version). So check there for more colors/styles.

Error and success

log.error(s, ...arguments) // Quick way to console log in red color
  .success(s, ...arguments) // Quick way to console log in green color

Same arguments as log(), but no style object

StartLoading

var timeout = log.startLoading(s, style) // Starts a console loading animation
log.clear(timeout) // Stops the loading animation
  • s: String to use with the loading symbol.
  • timeout: Can be anything really, if clear is called with an argument it stops an ongoing animation instead of clearing styles.

SetLoader

log.setLoader(symbol) // Changes loading symbol
  • symbol: String of which console loading symbol to use ("rotater", "numbers" or "dots").

SetLoopDepth

log.setLoopDepth(depth)
  • depth: Number for max recursion level depth to use when looping through objects and arrays. Default is 10.

ShowStringDetails

log.showStringDetails(show)
  • show: Boolean to show/hide all strings datatype and length info in console. Is false by default.
  • String details are always shown inside arrays and in objects though.

Tests

$ npm test

Author

Webbjocke

License

MIT

Changelog

1.0.0 (Aug 5, 2016)

  • Initial public release