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

graceful-console

v0.5.1

Published

Dectorator console module that adds color functionality, formatting, sorting, etc..

Downloads

2

Readme

graceful-console

Synopsis

Decorator console module that adds color, formatting, sorting, etc.. to the node console.

Code Example

The new console gives you more control. More colors. Line Numbers. Sorting. Etc... Contribute!

// Set a global variable called scribe
global.scribe = require('graceful-console');

// Use the global instance to log
scribe.tag('test').log('the frog jumped the boat');
scribe.warn({frog:1, water: 0});
scribe.error('it drowned');
scribe.tag('Sort Frog Array').sort(true).log(['Frog1', 'Frog3', 'Frog2']);

Drum role please... alt text

Get Started

Use NPM to install npm install graceful-console --save

Last step:

global.scribe = require('graceful-console');

API Reference

###scribe.settings(obj), scribe.options(obj)

Settings sets these options till they are unset. Options sets these options for the immediate next log, info, warn, error, critical, etc.

opts Choose the scribe options: write path, stack, time, and/or lvl.

  • write: path dictates where scribe should output a scribe log file too.
  • isStack: dictates weather or not to show line numbers and file names. This is resource intensive. Dont enable in production.
  • isTime: dictates weather or not to show a time stamp.
  • maxLvl: dictates how much information you want scribe to print: do you want to print all scribe messages or just errors? (scribe.ERROR || scribe.CRITICAL << scribe.WARN << scribe.ALL || scribe.INFO)
  • label: For advanced users! Instead use the alias scribe#warn, scribe#error, scribe#info, and scribe#critical.
  • lvl: For advanced users! Instead use the alias scribe#warn, scribe#error, scribe#info, and scribe#critical.
  • sort: Do not use! Instead use the alias scribe#sort.
  • tag: Do not use! Instead use the alias scribe#tag.

###scribe.log(str), scribe.error(str), scribe.info(str), scribe.warn(str), scribe.critical(str)

Takes a string str as the output tag. Prints str to stdout with newline. Eats the current options such as tag and sort.

scribe.log('I have a frog.');
scribe.info('He is there.');
scribe.warn('The frog might jump the boat.');
scribe.error('The frog jumped the boat.');
scribe.critical('The frog did not die.');

###scribe.tag(str)

Takes a string str as the output tag. The next log, error, warn, info will be tagged with the str.

scribe.tag('test').log('the frog jumped the boat');

###scribe.sort(arg)

Takes a function or a boolean arg. The next log, error, warn, info will be sorted.

scribe.tag('Sort Test Array').sort().log([1, 3, 2]);
scribe.tag('Sort Test Object').sort().log({1: 'a', 3: 'c', 2: 'b'});
scribe.tag('Sort Test Function Inveser').sort(function(a, b) { return b.value.charCodeAt(0) - a.value.charCodeAt(0)}).log({1: 'a', 3: 'c', 2: 	'b'});

###scribe.break(str)

Prints a new line.

scribe.break();

###scribe.chunk(func)

Takes a function func where every call to scribe chunks text using spacing and pretty formatting.

scribe.tag('chunk').chunk(() => {
	scribe.log(true);
	scribe.log(false);
	scribe.tag('string').log('A string');
	scribe.tag('printf').log('A manipulated string (%s) with number: %d', 'apple', 42);
	scribe.tag('number').log(1);
	scribe.log(1);
	scribe.log(true);
	scribe.log({me:1});
	scribe.log([1,2,3]);
	scribe.error([1,2,3]);
	scribe.error('');
	scribe.error(new Error("Errorrrs"));
	scribe.tag('Sort Test Array').sort().log([1, 3, 2]);
	scribe.tag('Sort Test Object').sort().log({1: 'a', 3: 'c', 2: 'b'});
	scribe.tag('Sort Test Function Inveser').sort(function(a, b) { return b.value.charCodeAt(0) - a.value.charCodeAt(0) }).log({1: 'a', 3: 'c', 2: 'b'});
});

###scribe.dir, scribe.assert, scribe.time, scribe.timeEnd

Alias to the console equivalent (i.e. console.dir, console.assert, etc). Refer to Node documentation for behavior https://nodejs.org/api/scribe.html#scribe_scribe_log_data

TODO

  • Update scribe to take into account toString when printing javascript objects
  • Add changelog to readme

License

MIT