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

logg

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logg

Logging library that allows for hierarchical loggers, multiple log levels, and flexible watching of log records.

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by40%
Maintainers
1
Weekly downloads
 
Created
Source

Node-Logging

This is a logging library for use with node.js. It decouples log reporting from publishing and is based on the Java API.

Installation

Fork the latest source from github.

or

npm install logg

Usage

Call getLogger(name) with the name of your class, namespace, or made up identifier.

Loggers expose fine(), info(), warn(), error() and log(level, args). These logging methods take variable arguments and will call sys.inspect on any objects that are passed. There is special handling for Error objects.

var logging = require('logg');

var logger = logging.getLogger('my.class);
logger.setLogLevel(logging.Level.WARN);
logger.info('This will not show up');
logger.warn('But warnings will', new Error('aargg')); 

Loggers are arranged in a hierarchy based on their names, separated by dots. Log reporting levels are inherited based on the hierarchy, INFO being the default level. For example, the following will silence everything but errors within the subproject namespace:

var a = logging.getLogger('project.subproject.foo');
var b = logging.getLogger('project.subproject.bar');
var c = logging.getLogger('project.subproject.baz');
var d = logging.getLogger('project.subproject.bam');

logging.getLogger('project.subproject').setLogLevel(logging.Level.SEVERE);

Every logger can have watchers associated with it, which will get called with a log record. Usually you'd just want to attach to root logger.

logging.registerWatcher(function(logRecord) {
  // Don't use sync API in real life...
  fs.writeFileSync('logs.log', JSON.stringify(logRecord) + '\n');
});

A default watcher is automatically registered which outputs to the console.

Keywords

FAQs

Package last updated on 26 Jul 2012

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