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

logule

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logule

An advanced logger for nodejs

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37
increased by37.04%
Maintainers
1
Weekly downloads
 
Created
Source

Logule

Logule is an advanced logging utility for nodejs. It is analogous to console.log and can take multiple arguments, but additionally it prefixes the current time, the log level, and optionally, a caller prefix.

Shortcut methods for the log levels are available as log.error, log.warn, log.info and log.debug. These methods are additionally chainable.

Usage

Here's with a prefix:

var Logger = require('logule');
var log = new Logger('prefix');
log.error("this is an error message");
log.warn("warning").info("info msg").debug("chained debug");

output!

Prefix Padding

Padding of the prefix level can be done by setting the second parameter in the constructor to the indentation level you want.

var log = new Logger('prefix', 16);

Now, the actual log messages will all begin 16 characters after the prefix starts. If the prefix is longer than the size limit, it will stand out from the crowd.

This is useful when different Logger instances is created in different places with different prefixes, and you want to line up the output.

No Prefix

If Logger is instantiated with no constructor arguments, then the output will simply not contain any prefixes and remove one delimiter. Everything will be aligned automatically.

Passing log around

To give submodules full control over what to send to the logger, simply pass down the log variable to them.

If, however, you only want a submodule to be able to log debugs for instance, you can make a sanitized logger function for them without access to .error, .warn and .info.

var debug = function(){
  return log.debug.apply(log, arguments);
};

Zalgo

̺̑ he comes

log.zalgo("no");

Installation

$ npm install logule

License

MIT-Licensed. See LICENSE file for details.

FAQs

Package last updated on 24 Nov 2011

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