From ba80dc1588e08015b058e423ccc74e54dba253d3 Mon Sep 17 00:00:00 2001 From: Christo Fogelberg Date: Sun, 8 Mar 2015 19:35:54 +0000 Subject: [PATCH] Trailing whitespace Sublime removed --- lib/connect-logger.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/connect-logger.js b/lib/connect-logger.js index 1f287c0..16eef50 100644 --- a/lib/connect-logger.js +++ b/lib/connect-logger.js @@ -1,8 +1,8 @@ "use strict"; var levels = require("./levels"); -var DEFAULT_FORMAT = ':remote-addr - -' + - ' ":method :url HTTP/:http-version"' + - ' :status :content-length ":referrer"' + +var DEFAULT_FORMAT = ':remote-addr - -' + + ' ":method :url HTTP/:http-version"' + + ' :status :content-length ":referrer"' + ' ":user-agent"'; /** * Log requests with the given `options` or a `format` string. @@ -52,7 +52,7 @@ function getLogger(logger4js, options) { // nologs if (nolog && nolog.test(req.originalUrl)) return next(); if (thislogger.isLevelEnabled(level) || options.level === 'auto') { - + var start = new Date() , statusCode , writeHead = res.writeHead @@ -60,7 +60,7 @@ function getLogger(logger4js, options) { // flag as logging req._logging = true; - + // proxy for statusCode. res.writeHead = function(code, headers){ res.writeHead = writeHead; @@ -77,7 +77,7 @@ function getLogger(logger4js, options) { level = levels.toLevel(options.level, levels.INFO); } }; - + //hook on end request to emit the log entry of the HTTP request. res.on('finish', function() { res.responseTime = new Date() - start; @@ -97,7 +97,7 @@ function getLogger(logger4js, options) { } }); } - + //ensure next gets always called next(); }; @@ -123,20 +123,20 @@ function format(str, req, res) { .replace(':referrer', req.headers.referer || req.headers.referrer || '') .replace(':http-version', req.httpVersionMajor + '.' + req.httpVersionMinor) .replace( - ':remote-addr', req.ip || req._remoteAddress || ( - req.socket && + ':remote-addr', req.ip || req._remoteAddress || ( + req.socket && (req.socket.remoteAddress || (req.socket.socket && req.socket.socket.remoteAddress)) )) .replace(':user-agent', req.headers['user-agent'] || '') .replace( - ':content-length', - (res._headers && res._headers['content-length']) || - (res.__headers && res.__headers['Content-Length']) || + ':content-length', + (res._headers && res._headers['content-length']) || + (res.__headers && res.__headers['Content-Length']) || '-' ) .replace(/:req\[([^\]]+)\]/g, function(_, field){ return req.headers[field.toLowerCase()]; }) .replace(/:res\[([^\]]+)\]/g, function(_, field){ - return res._headers ? + return res._headers ? (res._headers[field.toLowerCase()] || res.__headers[field]) : (res.__headers && res.__headers[field]); }); @@ -155,9 +155,9 @@ function format(str, req, res) { * NOT LOGGING http://example.com/hoge.gif and http://example.com/hoge.gif?fuga * LOGGING http://example.com/hoge.agif * 1.2 in "\\.gif|\\.jpg$" - * NOT LOGGING http://example.com/hoge.gif and + * NOT LOGGING http://example.com/hoge.gif and * http://example.com/hoge.gif?fuga and http://example.com/hoge.jpg?fuga - * LOGGING http://example.com/hoge.agif, + * LOGGING http://example.com/hoge.agif, * http://example.com/hoge.ajpg and http://example.com/hoge.jpg?hoge * 1.3 in "\\.(gif|jpe?g|png)$" * NOT LOGGING http://example.com/hoge.gif and http://example.com/hoge.jpeg @@ -175,15 +175,15 @@ function createNoLogCondition(nolog) { if (nolog) { if (nolog instanceof RegExp) { regexp = nolog; - } - + } + if (typeof nolog === 'string') { regexp = new RegExp(nolog); } - + if (Array.isArray(nolog)) { var regexpsAsStrings = nolog.map( - function convertToStrings(o) { + function convertToStrings(o) { return o.source ? o.source : o; } );