From 90e0ac89b15580dc779aa1d0b8b8c2a7c2393724 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Thu, 3 Nov 2011 14:34:49 -0600 Subject: [PATCH] in production (dev/beta/prod) use a more conventional logging format that includes timestamps. closes #234 --- bin/browserid | 2 +- bin/keysigner | 2 +- bin/verifier | 1 + lib/configuration.js | 2 ++ lib/logging.js | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/browserid b/bin/browserid index d69fe6767..32cca02f7 100755 --- a/bin/browserid +++ b/bin/browserid @@ -213,7 +213,7 @@ function router(app) { // request to logger, dev formatted which omits personal data in the requests app.use(express.logger({ - format: 'dev', + format: config.get('express_log_format'), stream: { write: function(x) { logger.info(typeof x === 'string' ? x.trim() : x); diff --git a/bin/keysigner b/bin/keysigner index ac5fa7f24..211cf1c19 100755 --- a/bin/keysigner +++ b/bin/keysigner @@ -57,7 +57,7 @@ var app = express.createServer(); // our server will log app.use(express.logger({ - format: 'dev', + format: config.get('express_log_format'), stream: { write: function(x) { logger.info(typeof x === 'string' ? x.trim() : x); diff --git a/bin/verifier b/bin/verifier index 8da38a12f..de9740281 100755 --- a/bin/verifier +++ b/bin/verifier @@ -54,6 +54,7 @@ var app = express.createServer(); // request to logger, dev formatted which omits personal data in the requests app.use(express.logger({ + format: config.get('express_log_format'), stream: { write: function(x) { logger.info(typeof x === 'string' ? x.trim() : x); diff --git a/lib/configuration.js b/lib/configuration.js index a71fc10d6..da7982c44 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -202,6 +202,8 @@ exports.performSubstitution = function(app) { } }; +g_config['express_log_format'] = (exports.get('env') === 'production' ? 'default' : 'dev'); + // At the time this file is required, we'll determine the "process name" for this proc // if we can determine what type of process it is (browserid or verifier) based // on the path, we'll use that, otherwise we'll name it 'ephemeral'. diff --git a/lib/logging.js b/lib/logging.js index 3e7feb5a1..6382a9030 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -38,7 +38,7 @@ * A very thin wrapper around winston for general server logging. * Exports a winston Logger instance in exports.logger with several functions * corresponding to different log levels. use it like this: - * + * * const logger = require('../libs/logging.js').logger; * logger.debug("you can probably ignore this. just for debugging."); * logger.info("something happened, here's info about it!"); -- GitLab