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

loggerjack

v0.2.0

Published

logging utilities

Downloads

7

Readme

LoggerJack

LoggerJack provides you simple with a simple but usefull namespaced logger.

npm install loggerjack
import Jack from 'loggerjack'

const Library = Jack.jack('library', 'INFO')
// create a namespaced Jack with key : 'library'

// log levels are : 'DEBUG' 'INFO' 'WARN' 'ERROR' 'NONE'
// lowercase is valid too

const comics = Library.logger('comics')
// create a namespaced logger with key : 'library.comics'
// inherit INFO log level from MyJack

comics.error('msg', {}, 0, ...)
// will log as error : library.comics: msg {} 0 ...
comics.warn('msg') // will log ...
comics.info('msg') // will log ...
comics.debug('msg') // will NOT log

const books = Library.logger('book', 'ERROR')
// override log level to DEBUG

const tests = books.logger('test', 'INFO')
// create a namespaced logger with key : 'library.book.test'

// Note : the .jack and .logger methods are the same, but typescipt will show only logging related methods on .logger result, and all on .jack result


/// now let's harness the power of Jack to change dynamically the logging level

Library.set('INFO')
// set self to INFO level

Library.set('DEBUG', 'book')
// will set key to DEBUG
Jack.set('DEBUG', 'library.book')
// is equivalent

books.debug('msg') // now logs msg
tests.debug('msg') // still at INGO level

Library
  .set('INFO')
  .set('DEBUG', 'book')
// .set can be chained


/// let's go a level higher and use patterns (GLOB inspired)

Library.set('INFO', '**')
// set self and every descendant to INFO level

Library.set('DEBUG', '**.other.test')
// book.test => unchanged
// other.test => DEBUG
// other.test.deep => unchanged
// deep.other.test.deep => DEBUG

Library.set('DEBUG', '*oo*')
// book => DEBUG
// book.test => unchanged
// other.test => unchanged

Library.set('DEBUG', '*oo*.**')
// book => nothing
// library.book => DEBUG
// library.book.test => DEBUG
// library.other.test => nothing


/// let's go even higher and imagine React is using loggerjack

Jack.set('DEBUG', 'react.**')
// get ready to a lot of logs...
// but it rocks !


/// Notes about logger level inheritance

Library.jack('a.b.c', 'INFO')
Library.jack('a.b', 'WARN')
Library.jack('a.b.c.d.e')
// without a level, it will take level of nearest declared parent
// in this case : INFO

// furthermore, patterns are kept in Jack memory
// so when we create a new jack, it will be checked against all patterns in parents
// starting from the nearest parent and the most recent pattern
// to the last ancestor and oldest pattern
// the check is done even if the jack is build with a level
Jack.set('DEBUG', '**.spec')
Jack.set('DEBUG', '**.test')
Library.set('NONE', '**.book.test')
Library.jack('book.shelf.spec', 'INFO')
// 'book.shelf.spec' checked against **.book.test' : false, go next
// 'library.book.shelf.spec' checked against **.test' : false, go next
// 'library.book.shelf.spec' checked against **.spec' : true, override 'INFO' by 'DEBUG'

// to sum up everything, at jack creation :
// inheritance < given level < existing pattern


/// Other notes

// Jacks are unique per key
Jack.jack('library') === Jack.jack('library') // true