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

modulog

v1.1.0

Published

a nice little logger for node.js that knows your modules auto-magically

Downloads

7

Readme

modulog

a nice little logger that knows your modules auto-magically

NPM

usage

kickAssModule.js

const logger = require('modulog')

logger('default');
logger.log('log');
logger.info('info');
logger.ok('ok');
logger.success('success');
logger.warn('warn');
logger.error('error');
logger.dir({0: {1: {2: {3: 'dir'}}}});
logger.dir({0: {1: {2: {3: 'dir'}}}}, {depth: 3});
logger.trace('trace');
logger.debug('debug');

stdout

» [kickAssModule] default
» [kickAssModule] log
ℹ [kickAssModule] info
✔ [kickAssModule] ok
✔ [kickAssModule] success
⚠ [kickAssModule] warn
✘ [kickAssModule] error
  [kickAssModule] { '0': { '1': { '2': [Object] } } }
  [kickAssModule] { '0': { '1': { '2': { '3': 'dir' } } } }
  [kickAssModule] Trace: trace
    at print (/Users/me/dev/my-node-app/node_modules/modulog/lib/modulog.js:28:23)
    at Object.<anonymous> (/Users/me/dev/my-node-app/test.js:17:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
🐞 [kickAssModule] debug

log levels

by default, all logger commands will send logs to stdout, except for debug and trace, which are switched off.

to change this behavior, use the LOG_LEVEL environment variable:

  • pass a single command name, e.g. 'debug', 'warn', to only switch on logging for that level.
  • use pipes to switch on several levels, e.g. 'trace|dir'.
  • to switch on logging for all commands, use '.*'.
  • to switch off logging entirely, use ' '.

in addition, if you run node with debug, --inspect, --debug or --debug-brk, debug and trace are switched on automatically.

examples

in your .env

# this will only switch on debug messages
LOG_LEVEL='debug'
# this will switch on trace, success and dir
LOG_LEVEL='trace|success|dir'

from the shell

# this will switch on warn and error
env LOG_LEVEL='warn|error' node my-app.js
# this will switch on logging for all commands
env LOG_LEVEL='.*' node my-app.js
# this will switch off logging entirely
env LOG_LEVEL=' ' node my-app.js

if you do any of these, debug/trace are switched on automatically:

node debug my-app.js
node --inspect my-app.js
node --debug my-app.js
node --debug-brk my-app.js