New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

log-skeleton

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-skeleton

Object that allows you to use the log API even if the logger was never initialized.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by12.5%
Maintainers
1
Weekly downloads
 
Created
Source

log-skeleton

build Status

log-skeleton is a simple object with methods .fatal, .error, .warn, .info, .debug and .trace. It is initalized with you favorite log instance, or nothing at all.

I.e. you can do either

var real_log = require('bunyan').createLogger({name: 'example'});
var log = require('log-skeleton')(real_log);

or

var log = require('log-skeleton')();

In the first case any simple API call to log will be forwarded to real_log, while in the latter case, every simple log API call will be silently ignored. It's meant to be a drop in tool for you module when you want to outsource the responsibility of creating a logger, but don't want to have a bunch of if (log) {} lying around.

Usage

var skeleton = require('log-skeleton');

module.exports = function (options) {
  var log = skeleton((options) ? options.log : undefined);
  ...
  log.info("Doesn't matter if options.log is undefined");
};

If options.log is undefined, the call to log.info does nothing. If it's a log object, the logger will log at the appropriate level.

The original log object is exposed at log.log in the above example, as to give you an access point to the real log object.

License

MIT

FAQs

Package last updated on 23 Aug 2015

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