Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leo-logger

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leo-logger

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

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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

Keywords

FAQs

Package last updated on 24 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc