Skip to content

Commit

Permalink
Updated examples and README
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvc committed May 27, 2010
1 parent 047248e commit 2e1622c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
36 changes: 30 additions & 6 deletions README.md
Expand Up @@ -2,18 +2,42 @@

## About

A node.js library for logging to multiple files
A node.js library for extremely customizable logging

## Features

* Multiple severity levels (debug, info, warn, fatal) by default
* Arbitrary user definable severity levels
* Arbitrary user definable severity levels with debug, info, warn, fatal by default
* Custom output formats
* Almost all events are listenable
* Writing to multiple files simultaneously
* Log rotation (reopening log files on demand)
* Custom output formats

## Example (Taken from example.js)
## Simple Example (From simple-example.js)

var
sys = require('sys'),
http = require('http'),
streamLogger = require('./lib/streamlogger'),
logger = new streamLogger.StreamLogger('log1.log');
//Defaults to info, debug messages will not be logged at info
logger.level = logger.levels.debug;

http.createServer(function(req, res) {
//Other default levels are .debug .warn and .fatal
logger.info("My Info message");

res.writeHead(200);
res.write("Hello!");
res.end();
}).listen(8000);

//If you want to rotate logs, this will re-open the files on sighup
process.addListener("SIGHUP", function() {
logger.reopen();
});

## Full (Ridiculous) Example (Taken from example.js)

var
sys = require('sys'),
path = require('path'),
Expand Down Expand Up @@ -60,7 +84,7 @@ A node.js library for logging to multiple files
res.writeHead(200);
res.write("Hello!");
res.close();
res.end();

//Setting a custom format, note that since this is an async lib
//setting the format here WILL affect messages outputted prior during this
Expand Down
2 changes: 1 addition & 1 deletion example.js
Expand Up @@ -44,7 +44,7 @@ http.createServer(function(req, res) {

res.writeHead(200);
res.write("Hello!");
res.close();
res.end();

//Setting a custom format, note that since this is an async lib
//setting the format here WILL affect messages outputted prior during this
Expand Down
21 changes: 21 additions & 0 deletions simple-example.js
@@ -0,0 +1,21 @@
var
sys = require('sys'),
http = require('http'),
streamLogger = require('./lib/streamlogger'),
logger = new streamLogger.StreamLogger('log1.log');
//Defaults to info, debug messages will not be logged at info
logger.level = logger.levels.debug;

http.createServer(function(req, res) {
//Other default levels are .debug .warn and .fatal
logger.info("My Info message");

res.writeHead(200);
res.write("Hello!");
res.end();
}).listen(8000);

//If you want to rotate logs, this will re-open the files on sighup
process.addListener("SIGHUP", function() {
logger.reopen();
});

0 comments on commit 2e1622c

Please sign in to comment.