Skip to content

Commit

Permalink
Merge pull request #80 from zettajs/custom-logging
Browse files Browse the repository at this point in the history
Custom Logging
  • Loading branch information
Matthew Dobson committed Oct 10, 2014
2 parents 378a88b + eac9c99 commit bcac19c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sample/CustomLogging/server.js
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);

0 comments on commit bcac19c

Please sign in to comment.