Skip to content

Instantly share code, notes, and snippets.

@cranic
Last active August 29, 2015 13:58
Show Gist options
  • Save cranic/9956168 to your computer and use it in GitHub Desktop.
Save cranic/9956168 to your computer and use it in GitHub Desktop.
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