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

leo-logger

v1.0.4

Published

NodeJS Logger by LeoInsights. Logging the way it should be!

Downloads

6,880

Readme

Leo-Logger

Such an awesome logger that we had to break it out from the LEO SDK and make it its own project!

Available methods

  • sub
  • info
  • json
  • time
  • timeEnd
  • log
  • debug
  • error
  • warn
  • trace
  • configure

Available configuration options

  • a = all
  • t = time
  • i = info
  • d = debug
  • e = error
  • w = warn
  • x = trace
  • j = json
  • T = printTimestamp

Usage example:

export LEO_LOGGER='/.*/d'
export LEO_LOGGER='/my-logger/wei;/.*/ei'

Working with namespaces

You can log logs for specific namespaces by passing a string when requiring the leo-logger. Example:

const logger = require('leo-logger')('my-special-namespace');

When you use a namespace, logging works the same, but the output will be prefixed with the namespace:

logger.log('My namespaced log');
// outputs: my-special-namespace my namespaced log

If you want to display logs for certain namespaces only, you can adjust LEO_LOGGER to match the namespace.

# Example outputting all logs for my-special-namespace
export LEO_LOGGER='/my\-special\-namespace/a'

You may notice in the previous example how it appears we’re using regex. This allows you to employ more powerful namespace logging. As an example, let’s say you have a shopping cart, and you want to have logs specific to the checkout process. Each of the checkout pages would include the leo-logger. I'm going to use an example of 2 checkout pages, which would look like this:

const logger = require('leo-logger')('checkout-payment');
const logger = require('leo-logger')('checkout-process-order');

Then if you want to display logs for the process-order page, you would do this:

export LEO_LOGGER='/checkout\-process\-order/a'

But if you want to display logs for all checkout pages, you can use the power of regex to select everything starting with “checkout”:

export LEO_LOGGER='/checkout.*/a'

Loggers

logger.log('my logged message');
logger.info('my info');
logger.debug('just some debugging code');

Timers

// start a timer
logger.time('myTimer');
// stop a timer
logger.timeEnd('endTimer');

To-Do

More documentation with examples with code and output.

Support

Want to hire an expert, or need technical support? Reach out to the Leo team: https://leoinsights.com/contact