diff --git a/bin/browserid b/bin/browserid index 5802ba36d9abc4a58aca7e50b1b04f04ba02047c..718dc44ba0037b3e0fff522e3c7197f058ebccdd 100755 --- a/bin/browserid +++ b/bin/browserid @@ -135,7 +135,7 @@ app.use(function(req, resp, next) { var static_root = path.join(__dirname, "..", "resources", "static"); -app.use(cachify.setup(assets(config.get('supported_languages')), +app.use(cachify.setup(assets(config.get('supported_languages')), { prefix: 'v', production: config.get('use_minified_resources'), diff --git a/config/local.json b/config/local.json index d8726dfff310eae2d0ec7f58f8f76a5429a6dad9..960bdf2e9f0c71700529ca8dd2b4c0afa43f4a00 100644 --- a/config/local.json +++ b/config/local.json @@ -8,7 +8,7 @@ "database": { "driver": "json" }, - "express_log_format": "dev", + "express_log_format": "dev_bid", "email_to_console": true } diff --git a/config/production.json b/config/production.json index 966f309512f9f616d7ceba5ad02d45cec04aa2c1..972c2899fa85ae694dcb77b69163f25599a4ca71 100644 --- a/config/production.json +++ b/config/production.json @@ -33,7 +33,7 @@ "debug_lang": "it-CH", // locale directory should be overridden "locale_directory": "/home/app/code/locale", - "express_log_format": "default", + "express_log_format": "default_bid", "email_to_console": false, // var path should be overridded // "var_path": "xxx", diff --git a/lib/configuration.js b/lib/configuration.js index 1b443b5754a3c9a52f9afb56814c7a37d673c622..0676211e8bf1ed647d67c90ee90bcd14ea58caf1 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -22,6 +22,9 @@ fs = require('fs'), convict = require('convict'), cjson = require('cjson'); +// Side effect - Adds default_bid and dev_bid to express.logger formats +require('./custom_logger'); + // verify the proper version of node.js is in use try { var required = 'unknown'; @@ -154,7 +157,7 @@ var conf = module.exports = convict({ debug_lang: 'string = "it-CH"', supported_languages: 'array { string }* = [ "en-US" ]', locale_directory: 'string = "locale"', - express_log_format: 'string [ "default", "dev" ] = "default"', + express_log_format: 'string [ "default_bid", "dev_bid", "default", "dev", "short", "tiny" ] = "default"', keysigner_url: { format: 'string?', env: 'KEYSIGNER_URL' diff --git a/lib/custom_logger.js b/lib/custom_logger.js new file mode 100644 index 0000000000000000000000000000000000000000..6ba0514bf0d4d63b9d6944dcfd1c32cc8fda9dc9 --- /dev/null +++ b/lib/custom_logger.js @@ -0,0 +1,21 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * Enhances connect logger middleware - custom formats. See lib/configuration for usage. + * + * Note: No exports, ya I feel dirty too. + */ +var logger = require('express').logger; + +logger.format('default_bid', + ':remote-addr - - :date-millis ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"'); + +logger.format('dev_bid', ':date-millis :method :url :status :response-time ms'); + +logger.token('date-millis', function (req) { + var d = req._startTime, + t = '' + d.getTime(); + return '[' + d.toUTCString() + ']@' + t.slice(-4); +}); \ No newline at end of file