-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from zettajs/custom-logging
Custom Logging
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var zetta = require('../../'); | ||
|
||
// allows a user to use any logger | ||
var winston = require('winston'); | ||
|
||
// or | ||
|
||
var bunyan = require('bunyan').createLogger({name: 'myapp'}); | ||
|
||
zetta() | ||
|
||
.logs(function(log) { | ||
// logs passes an internal logs object. | ||
|
||
log.on('log', function(type, msg, data) { | ||
// type = info/warn/error | ||
// msg = "Websocket connection for peer "local" established." | ||
// data.component = http_server | ||
// data.date = ... | ||
}); | ||
|
||
// follows above but filters on type | ||
log.on('info', function(msg, data) { | ||
winston.info(msg, data); | ||
}); | ||
|
||
log.on('warn', function(msg, data) { | ||
bunyan.log(data, msg); // bunyan does it the other way. | ||
}); | ||
|
||
log.on('error', function(msg, data) { | ||
}); | ||
|
||
}) | ||
.listen(3000); |