Permalink
Browse files

Updated examples and README

  • Loading branch information...
1 parent 047248e commit 2e1622c5607479a1d867a07085d69d1e30bef767 @andrewvc committed May 27, 2010
Showing with 52 additions and 7 deletions.
  1. +30 −6 README.md
  2. +1 −1 example.js
  3. +21 −0 simple-example.js
View
@@ -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'),
@@ -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
View
@@ -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
View
@@ -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.