diff --git a/lib/connect-logger.js b/lib/connect-logger.js index 8162b50..a53f7e0 100644 --- a/lib/connect-logger.js +++ b/lib/connect-logger.js @@ -89,12 +89,12 @@ function getLogger(logger4js, options) { if(res.statusCode >= 400) level = levels.ERROR; } if (thislogger.isLevelEnabled(level)) { - var default_tokens = assemble_tokens(req, res); + var combined_tokens = assemble_tokens(req, res, options.tokens || []); if (typeof fmt === 'function') { - var line = fmt(req, res, function(str){ return format(str, default_tokens); }); + var line = fmt(req, res, function(str){ return format(str, combined_tokens); }); if (line) thislogger.log(level, line); } else { - thislogger.log(level, format(fmt, default_tokens)); + thislogger.log(level, format(fmt, combined_tokens)); } } }); @@ -113,7 +113,19 @@ function getLogger(logger4js, options) { * @param {Array} custom_tokens [{ token: string-or-regexp, replacement: string-or-replace-function }] * @return {Array} */ -function assemble_tokens(req, res) { +function assemble_tokens(req, res, custom_tokens) { + var array_unique_tokens = function(array) { + var a = array.concat(); + for(var i=0; i