Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Logging Framework for Node.js

branch: master

Merge pull request #8 from jirwin/add_timestamp_to_console_sink

fix(console-sink): Include a timestamp when using the console sink.
latest commit 5ca17276a3
Paul Querna authored February 25, 2013
Octocat-spinner-32 lib fix(console-sink): Include a timestamp when using the console sink. February 25, 2013
Octocat-spinner-32 tests lib: graylog: don't create an _id field November 27, 2012
Octocat-spinner-32 LICENSE stubs March 19, 2011
Octocat-spinner-32 NOTICE stubs March 19, 2011
Octocat-spinner-32 README.md Merge pull request #4 from ddispaltro/patch-1 January 20, 2012
Octocat-spinner-32 package.json Bump npm version. July 17, 2011
README.md

Welcome to Log Magic.

This project is usable. It doesn't do everything it should, yet.

The goal is to have a fast and easy to use logging subsystem that can be dynamically reconfigured to provide insight into production systems.

Logmagic does its magic by generating objects with generated functions that are only modified when the logging system is reconfigured, thus your entire logging path is contained within long-lived functions that V8 is able to JIT.

Getting Started

If you had a file named like, "lib/foo/bar.js", at the top of it, you would put the following:

var log = require('logmagic').local('mylib.foo.bar');

Then inside bar.js, you would just use the logger like any normal logger:

log.info("Hello!")
log.error("By default, format strings are not used.", {SOME_VAR: "myvalue"})
log.errorf("Just add 'f' to any log method, and you get format strings too: ${SOME_VAR}", {SOME_VAR: "myvalue"})

In any other part of your application, you can reconfigure the logging subsystem at runtime, making it easy to change log levels for specific modules dynamically.

var logmagic = require('logmagic');
logmagic.registerSink("mysink", function(module, level, message) { console.log(message); });

/* Send Info an higher in the root logger to stdout */
logmagic.route("__root__", logmagic.INFO, "stdout")

/* Reconfigure all children of mylib to log all debug messages to your custom sink */
logmagic.route("mylib.*", logmagic.DEBUG, "mysink")

Builtin sinks include:

  • stderr
  • Graylog2-style JSON to stderr

Future features:

Something went wrong with that request. Please try again.