diff --git a/browserid/app.js b/browserid/app.js index 2f020e2bcec9d7a07493cce35f927bd31a420c1e..8adc439ed3ca48f9e5f28e3a62d6a63eb28d795d 100644 --- a/browserid/app.js +++ b/browserid/app.js @@ -54,7 +54,7 @@ secrets = require('./lib/secrets.js'), db = require('./lib/db.js'), configuration = require('../libs/configuration.js'), substitution = require('../libs/substitute.js'); -logging = require("../libs/logging.js"); +metrics = require("../libs/metrics.js"); // open the databse db.open(configuration.get('database')); @@ -81,7 +81,7 @@ function router(app) { // this should probably be an internal redirect // as soon as relative paths are figured out. app.get('/sign_in', function(req, res, next ) { - logging.userEntry('browserid', req); + metrics.userEntry('browserid', req); res.render('dialog.ejs', { title: 'A Better Way to Sign In', layout: false, diff --git a/browserid/lib/db_mysql.js b/browserid/lib/db_mysql.js index c86e72897351d6e0a6634c71db5d4dd6e14ae03e..964281d49462877d7396d83a70f0c79d4ed72113 100644 --- a/browserid/lib/db_mysql.js +++ b/browserid/lib/db_mysql.js @@ -63,7 +63,7 @@ const mysql = require('mysql'), secrets = require('./secrets'), -logger = require('../../libs/logging.js'); +metrics = require('../../libs/metrics.js'); var client = undefined; @@ -83,7 +83,7 @@ function logUnexpectedError(detail) { var where; try { dne; } catch (e) { where = e.stack.split('\n')[2].trim(); }; // now log it! - logger.log('db', { type: "unexpected", message: "unexpected database failure", detail: detail, where: where }); + metrics.report('db', { type: "unexpected", message: "unexpected database failure", detail: detail, where: where }); } // open & create the mysql database @@ -426,7 +426,7 @@ exports.pubkeysForEmail = function(email, cb) { exports.removeEmail = function(authenticated_email, email, cb) { exports.emailsBelongToSameAccount(authenticated_email, email, function(ok) { if (!ok) { - logger.log('security', { type: 'security', msg: authenticated_email + ' attempted to delete an email that doesn\'t belong to her: ' + email }); + metrics.report('security', { type: 'security', msg: authenticated_email + ' attempted to delete an email that doesn\'t belong to her: ' + email }); cb("authenticated user doesn't have permission to remove specified email " + email); return; } diff --git a/libs/metrics.js b/libs/metrics.js index 0d4c3422d27fe84732274aad15652f1d75025a4f..1e9137e7da76dd9615d24ea2d1df9c3a238f8d1e 100644 --- a/libs/metrics.js +++ b/libs/metrics.js @@ -50,7 +50,6 @@ var LOGGERS = []; function mkdir_p(p) { if (!path.existsSync(p)) { mkdir_p(path.dirname(p)); - console.log("mkdir", p); fs.mkdirSync(p, "0755"); } } @@ -74,7 +73,7 @@ function setupLogger(category) { } // entry is an object that will get JSON'ified -exports.log = function(category, entry) { +exports.report = function(category, entry) { // entry must have at least a type if (!entry.type) throw new Error("every log entry needs a type"); @@ -91,7 +90,7 @@ exports.log = function(category, entry) { // utility function to log a bunch of stuff at user entry point exports.userEntry = function(category, req) { - exports.log(category, { + exports.report(category, { type: 'signin', browser: req.headers['user-agent'], rp: req.headers['referer'], diff --git a/verifier/app.js b/verifier/app.js index 9b8f8e1989ba94e9bbb2187d89e67875bb028d87..1116b881ffdce383851c9925926fd8f21d62077b 100644 --- a/verifier/app.js +++ b/verifier/app.js @@ -40,7 +40,7 @@ const path = require('path'), idassertion = require('./lib/idassertion.js'), jwt = require('./lib/jwt.js'), express = require('express'); - logging = require('../libs/logging.js'); + metrics = require('../libs/metrics.js'); // create the var directory if it doesn't exist var VAR_DIR = path.join(__dirname, "var"); @@ -72,7 +72,7 @@ function doVerify(req, resp, next) { audience, function(payload) { // log it! - logging.log('verifier', { + metrics.report('verifier', { type: 'verify', result: 'success', rp: payload.audience @@ -88,7 +88,7 @@ function doVerify(req, resp, next) { resp.json(result); }, function(errorObj) { - logging.log('verifier', { + metrics.report('verifier', { type: 'verify', result: 'failure', rp: audience @@ -98,7 +98,7 @@ function doVerify(req, resp, next) { ); } catch (e) { console.log(e.stack); - logging.log('verifier', { + metrics.report('verifier', { type: 'verify', result: 'failure', rp: audience