Last active
August 29, 2015 13:58
-
-
Save cranic/9956168 to your computer and use it in GitHub Desktop.
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
var express = require('express'); | |
var winston = require('winston'); | |
var app = express(); | |
// Criando uma única instância do winston | |
var logger = new (winston.Logger)({ | |
transports: [ | |
new (winston.transports.Console)(), | |
new (winston.transports.File)({ filename: 'somefile.log' }) | |
] | |
}); | |
app.get('/api/v1/users', function(req, res){ | |
// se vier 1 milhão de resquests, vou usar a mesma instância | |
logger.log('hit', req.url); | |
}); | |
app.get('/api/v1/videos', function(req, res){ | |
// se vier 1 milhão de resquests, vou usar a mesma instância | |
logger.log('hit', req.url); | |
}); | |
app.get('/api/v1/rss', function(req, res){ | |
// se vier 1 milhão de resquests, vou usar a mesma instância | |
logger.log('hit', req.url); | |
}); | |
app.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment