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

autocon

v1.0.1

Published

Javascript console.log re-invented. Taking the console.log to a new printing model without any code edit.

Downloads

1

Readme

autocon.js - Re-inventing the console.log.

This simple module with

Why ?

I love using console.log when I'm writing code. I love to test with it, debug with it or just writing regular runtime logs. console.log have a lot of features like console.warn or console.error - But eventually I'm still using console.log.

This module with log your logs with a smarter way with No Code Change!

How?

This modules changes the console.log core functionality - that's why you will NOT write any changes to your code to use it. Each time you send console.log, it detects the words and objects and searches for keys like 'error', 'test', 'success' and so on, and matching the correct color.

More details in Usage section.

Installation

npm install autocon

CDN library not available yet.

Usage

Add this to the start of your program:

require('autocon').init()

And that's it! Simple.

If you would like to disable the word detection you can set:

require('autocon').init({enableIntelligence:false})

By configuring this, the logs will print only the date & time.

Maped strings for now:

errorStrings: ['err', 'problem', 'fail'],
passedStrings: ['passed', 'complete', 'success'],
testStrings: ['test', 'check'],

you can add/edit your own keys by overwriting the existing setting:

require('autocon').init({passedStrings:['my-own-string', 'my-second-string']})

Each log that contains the string (even part of it) it will match the correct color, For example: If the errorStrings is ['err'] The next logs will be printed in red color:

console.log('err in line 3')
console.log('error in line 5')
console.log('multiple errors has occurred')

Example

Example node.js program that demonstrate logs usage:

require('autocon').init()

console.log("Starting with Node.js script..")

let x = 4
let y = 12

console.log("Sum of two numbers: ", x+y)

console.log("Testing new feature..") //Contains "test" = will be printed in pink color
try{
	/*
	*	New Feature Algorithm
	*/
	throw new Error()
}catch{
	console.log("Failed with Feature No' 1") //Contains "fail" = will be printed in red color
}

console.log("Simulating long runtime code..")
/*
*	Uploading file etc.
*/
setTimeout(() => {
	console.log("Successfully Completed!") //Contains "success" = will be printed in green color
}, 1000)

setTimeout(() => {
	console.log("Debugging objects: ", {key1: "value1", key2: "Error"}) //Contains "error" = will be printed in red color
	console.log("Another object without e-r-r-o-r strings: ", {key1: "value1", key2: "val2"}) //Not contains any special keys, will be printed in white
}, 2000)

Before - Simple logs:

After:

If you already have a node.js program, to combine this module you dont need to change your console.log code lines.