From: Aleksander Ɓukasz Date: Mon, 30 Dec 2013 12:29:07 +0000 (+0100) Subject: logging: pass logger name to the handler X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/7723bc8892a423d246035a0d7449193193fc5c8a logging: pass logger name to the handler --- diff --git a/src/fnpjs/logging/handlers.js b/src/fnpjs/logging/handlers.js index 966af4e..c5b6990 100644 --- a/src/fnpjs/logging/handlers.js +++ b/src/fnpjs/logging/handlers.js @@ -4,7 +4,7 @@ define(function() { return { - raven: function(msg, level, data) { + raven: function(record) { /* global window */ if(!window.Raven) { return; @@ -12,15 +12,15 @@ return { var ravenData = {}; - if(data.exception) { - window.Raven.captureException(data.exception); + if(record.data.exception) { + window.Raven.captureException(record.data.exception); } else { - Object.keys(data || {}).forEach(function(key) { - ravenData[key] = data[key]; + Object.keys(record.data || {}).forEach(function(key) { + ravenData[key] = record.data[key]; }); ravenData.tags = ravenData.tags || {}; - ravenData.tags.level = level; - window.Raven.captureMessage(msg, ravenData); + ravenData.tags.level = record.level; + window.Raven.captureMessage(record.message, ravenData); } } }; diff --git a/src/fnpjs/logging/logging.js b/src/fnpjs/logging/logging.js index e68302d..4237f65 100644 --- a/src/fnpjs/logging/logging.js +++ b/src/fnpjs/logging/logging.js @@ -37,9 +37,14 @@ _.extend(Logger.prototype, { } if(levels.indexOf(handlerLevel) !== -1 && levels.indexOf(level) >= levels.indexOf(handlerLevel)) { - handler(message, level, data); + handler({ + message: message, + level: level, + loggerName: this.name, + data: data + }); } - }); + }.bind(this)); } if(this.config.propagate && this.name) { var logger = new Logger(this.name.split('.').slice(0, -1).join('.')); diff --git a/src/fnpjs/logging/logging.test.js b/src/fnpjs/logging/logging.test.js index 5876f5a..6baf049 100644 --- a/src/fnpjs/logging/logging.test.js +++ b/src/fnpjs/logging/logging.test.js @@ -31,8 +31,8 @@ var log = { }; // Loggin handler that just writes to the global logger object -var testLoggingHandler = function(msg) { - log.append(msg); +var testLoggingHandler = function(record) { + log.append(record.message); }; describe('Logging', function() {