Transport independant JSON logging for node.js.
quantum - n. - A discrete quantity of energy proportional in magnitude to the frequency of the radiation it represents.
Quantum is available through npm.
npm install quantum
To get started using Quantum in your application, creata a new logger and tag it with a namespace. Before logging anything you will need to select the log levels to be bound to your log instance, and indicate any number of transports you wish you use. Here are a few examples.
var quantum = require'quantum'log = quantum'my-app';// Basic console logging.loglevels'syslog'usequantumconsole theme: 'default'start;// Environment based configuration.logconfigure'development'logusequantumconsoleusequantumwriteFile__dirname + '/dev-logs';;logconfigure'production'var logopts = exclude: 'debug' ;logusequantumwriteFile__dirname + '/prod-logs' logoptsusequantumbroadcast'ws://logger.my-app.com' logopts;;logstart;// Log something!logwrite'info' 'You really should know about this' foo: 'bar' ;log.info'You really should know about this.' foo: 'bar' ;
quantum command (when installed globally) allows for observation of ongoing logging activites.
Use it to monitor currenting currning services or
tail like behavior for JSON formatted log files.
Quantum https://github.com/qualiancy/quantum quantum --help Show CLI help contents quantum --version Show the current version quantum watch service <options> Observe all log events on a quantum collection service -p, --port  The port the collector is running on. -h, --host [localhost] The host the service is running on. -t, --theme [default] Console theme to display log events on. Use `none` to disable. -f, --file Save incoming log events to this file in JSON format. quantum watch file <options> Observe all log events on a quantum based json log file. -l, --levels [syslog] Levels used in the file. Ignored if theme is `json` -t, --theme [default] Console theme to display log events on. -f, --file Listen for log events on this file. Expected JSON format. quantum collect <options> Starts a Quantum collection service. -l, --levels [syslog] Levels to use. Recommended log nodes use the same. -p, --port  The port the collector will listen on. -t, --theme [default] Console theme to display log events on. Use `none` to disable. -f, --file Save incoming log events to this file in JSON format.
Levels are defined by a string to numerical reference. Each level should also have a color associated with it for use with a reporter that supports colorful output.
- Syslog (default)
By using levels, a number of helper methods are mounted ont
Transports are used to change where the logs are written.
Console logging provides a number of themes to stylize the output.
var quantum = require'quantum'log = 'my-app';logusequantumconsole theme: 'default' ;logstart;log.info'Hello Universe';
File logging will stream log data to file in line-delimeted JSON format.
var log = 'my-app';logusequantumwriteFile__dirname + '/logs';logstart;log.info'Hello Universe';
Broadcast logging will broadcast events through websockets. Quantum also comes with with a service so you can create my application that all broadcast to a single log collection service. More information below.
var log = 'my-app';logusequantumbroadcast'ws://localhost:5000';logstart;log.info'Hello Universe';
The Quantum collection service is for use with the broadcast transport. The service will proxy incoming log events to a new Quantum logger. This will allow for multiple logger collection by a single service.
The following example will proxy all incoming broadcasted log events to the file transport.
var log = nwe quantumLogger'quantum-collector';logusequantumwriteFile__dirname + '/logs';loginit;var service = quantumcreateServicelog;servicelisten5000if err throw err;log.info'Quantum collecting on port 5000';;
$ make test
Interested in contributing? Fork to get started. Contact @logicalparadox if you are interested in being regular contributor.
(The MIT License)
Copyright (c) 2012 Jake Luer firstname.lastname@example.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.