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

console-log-formatter

v1.0.3

Published

simple lightweight console.log formatter that makes your logs stand out from others', and easier to find and cleanup

Downloads

4

Readme

Console.log Formatter

Make your console.log more visible and stand out from others'. See the file path and the line number where the console.log is placed to make cleaning up easier.

Installation

npm install -g console-log-formatter

Usage

Import the package in the lower-level code, and its features will be available throughout the code base.
You can provide configuration options to the constructor to override default settings for all usages or to individual calls in the last argument. Options passed as an argument take precedence over constructor.

require('console-log-formatter')({
  style: { path: { text: 'red'} }
});
import formatter from 'console-log-formatter';
formatter({
  style: {path: { text: 'red'} }
});
console.log("Hello", "world", {
  clf: true, 
  style: { arguments: { text: 'yellow'} }
})

Options

  • clf (Boolean)
    • required to be set to true only when options are passed as the last argument to a function. It tells the formatter that this argument is a configuration object
  • disable (Boolean)
    • use when you need to disable formatting on certain functions
  • exclude (RegEx)
    • by default, anything in node_modules is not formatted. Pass your own RegEx to define paths to the files to be excluded from formatting. To apply formatting to everything, set to null.
  • path (Boolean)
    • by default, the path to the file with the line number of where the function is called from is logged in front of all other arguments. To exclude, set to false.
  • style (Object)
    • the styling object to describe the colors of the text and background of file paths and function arguments
    • the following colors are available to choose from:
      black, red, green, yellow, blue, magenta, cyan, white
      Also available the following effects:
      bright, dim, underline, blink, reverse, hidden
    • path (Object)
      • options defining format of the file path
      • text
      • background
      • effect
    • arguments (Object or Array of object)
      • options defining format of function arguments. You can pass a single object to define formatting for all arguments, or an array of objects to define formatting for individual argument. To skip a single argument in the array and have it take the default format, pass undefined in its place.
      • text
      • background
      • effect
  • wrappers (Number)
    • if you notice that the wrong file name is given, you might be using other console.log wrapper package(s). Try setting this property to the number of packages you are using. Probably no more than 1. Defaults to 0. You wouldn't need this option if everything looks correct.

Functions

log

your good old console.log

trace

and console.trace

timeStamp

console.log with time stamp added to the front

timeDiff(Date, [...other args])

logs the time difference in ms from the time passed as argument until now

const date = new Date();
setTimeout(() => {
	console.timeDiff(date, 'time', 'diff')
}, 150);