forked from andrewvc/node-streamlogger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |