Connect(およびExpress)の一部であるロガーミドルウェアを使用する場合、応答などにフラグを設定するなどして、特定の要求のロギングを無効にできるようにしたいと思います。
私はなんとか言ってそれをすることができました:
res.doNotLog = true;
次に、logger.js(Connectモジュールの一部)の奥深くに、
if(res.doNotLog) return;
正しい場所に。しかしもちろん、モジュール自体のコードを変更したくはありません。モジュールをハックせずに同じことを起こさせる方法はありますか?
編集:
これはうまくいきました:
var app = _express.createServer();
// set 'hello' routing...note that this is before middleware
// so it won't be logged
app.get('/sayhello', function(req, res) {res.send("hey");});
// configure middleware: logging, static file serving
app.configure(function() {
app.use(_express.logger());
app.use(_express.static(__dirname + '/www'));
});
// set 'goodbye' routing...note that this is after middleware
// so it will be logged
app.get('/saygoodbye', function(req, res) {res.send("later...");});