From f7fe0b0dc470ea0cc1581ec052fce64141dc1b9b Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Wed, 17 Aug 2011 18:27:32 +0300 Subject: [PATCH] determine 'process type' and prepend it to metrics log - issue #169 --- libs/configuration.js | 11 +++++++++++ libs/metrics.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/configuration.js b/libs/configuration.js index 333d9598b..84c179bb5 100644 --- a/libs/configuration.js +++ b/libs/configuration.js @@ -130,3 +130,14 @@ exports.performSubstitution = function(app) { } }; +// 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'. +if (process.argv[1] == path.join(__dirname, "..", "browserid", "run.js")) { + g_config['process_type'] = 'browserid'; +} else if (process.argv[1] == path.join(__dirname, "..", "verifier", "run.js")) { + g_config['process_type'] = 'verifier'; +} else { + g_config['process_type'] = 'ephemeral'; +} + diff --git a/libs/metrics.js b/libs/metrics.js index ae0aaf354..8b23a3e0a 100644 --- a/libs/metrics.js +++ b/libs/metrics.js @@ -80,7 +80,7 @@ function setupLogger() { else mkdir_p(log_path); - var filename = path.join(log_path, "metrics.json"); + var filename = path.join(log_path, configuration.get('process_type') + "-metrics.json"); LOGGER = new (winston.Logger)({ transports: [new (winston.transports.File)({filename: filename})] -- GitLab