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

min-log

v2.6.1

Published

Better Logger with Custom Level and Outputer Taking over the original console

Downloads

855

Readme

min-log

browser_console

Better Logger with Custom Level and Outputer Taking over the original console

Support All Browsers which can Display on page or in Console, for Phone and old IE debugging, support wechat miniprogram

Example page

Installation

npm i min-log

Usage

var log = require('min-log')

log.debug('hello')

Direct Replace console

If you already has a project with console.log, just add a plugin to webpack config

then min-log will take over all consoles and hide all logs by default

plugins: [
  new webpack.ProvidePlugin({
    console: 'min-log'
  })
]

If want have logger with namespace

e.g. animal.js, use filename as log namespace to take over console

const console = require('min-log').getLogger('animal')

Advanced Usage

debug with namespace like package name

var log = require('min-log').getLogger('com:foo')

log.debug('this file log')

Run Debug Code Block

var log = require('min-log')
if (log.isDebugEnabled()) {
  doSomeMockThing()
}

Log History

min-log default enable history, default history size is 3000

Api | Description --- | --- log.setHistorySize(1000) | Set history size log.disableHistory() | Disable history log.getHistory() | Get history log.clear() | Clear history log.save() | Save history

Debug Level

Set Level

log.setLevel('debug') // set debug level

Level | Description --- | --- verbose | Detail and verbose debug log only developper cares debug | Debug log only developper cares info | Normal info user should care like login or logout warn | Some waring user should care like cookie expired error | Some serious error user should care like server return error fatal | Some fatal error which will crash the program

Outputer

Set Outputer

log.setOutputer('browser_color') // set browser color outputer

Outputer | Usage --- | --- console | Simple console output like console.log node_console | Print log with color in node browser_console | Print log with color in browser browser_html | Print log in document by html (for old IE or phone website) vconsole | Remote call vConsole to print log eruda | Remote call Eruda to print log

Debug Style

If you like tj@debug and just use debug level, you can do this

var debug = require('min-log/debug')('http')

debug('booting')

Set Config

You can set log config for min-log

Name | Purpose --- | --- log_name | Enables/disables specific debugging namespaces log_level | Set log level like debug log_outputer | Set outputer like browser_html

min-log will try to get user config from three ways in order

  1. Query in page url e.g. my.site.com/path?log_name=*&log_level=debug&log_output=browser_html
  2. localStorage e.g. localStorage.log_level = debug
  3. Environment e.g. log_level=debug log_name=main* node app.js

Other Config

set log colors

log.setColors(['#f8f8f2', 'goldenrod', '#66d9ef', '#a6e22e', '#e6db74', '#f92672'])

set log namespace prefix

log.setPrefix('com:company:')

Formatter

TODO

Formatter | Representation --- | --- %O | Pretty-print an Object on multiple lines %o | Pretty-print an Object all on a single line %s | String %d | Number %j | JSON %% | Single percent sign ('%'). This does not consume an argument