logging: pass logger name to the handler
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Dec 2013 12:29:07 +0000 (13:29 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Dec 2013 12:29:07 +0000 (13:29 +0100)
src/fnpjs/logging/handlers.js
src/fnpjs/logging/logging.js
src/fnpjs/logging/logging.test.js

index 966af4e..c5b6990 100644 (file)
@@ -4,7 +4,7 @@ define(function() {
 
 
 return {
 
 
 return {
-    raven: function(msg, level, data) {
+    raven: function(record) {
         /* global window */
         if(!window.Raven) {
             return;
         /* global window */
         if(!window.Raven) {
             return;
@@ -12,15 +12,15 @@ return {
 
         var ravenData = {};
 
 
         var ravenData = {};
 
-        if(data.exception) {
-            window.Raven.captureException(data.exception);
+        if(record.data.exception) {
+            window.Raven.captureException(record.data.exception);
         } else {
         } 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 = ravenData.tags || {};
-            ravenData.tags.level = level;
-            window.Raven.captureMessage(msg, ravenData);
+            ravenData.tags.level = record.level;
+            window.Raven.captureMessage(record.message, ravenData);
         }
     }
 };
         }
     }
 };
index e68302d..4237f65 100644 (file)
@@ -37,9 +37,14 @@ _.extend(Logger.prototype, {
                 }
 
                 if(levels.indexOf(handlerLevel) !== -1 && levels.indexOf(level) >= levels.indexOf(handlerLevel)) {
                 }
 
                 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('.'));
         }
         if(this.config.propagate && this.name) {
             var logger = new Logger(this.name.split('.').slice(0, -1).join('.'));
index 5876f5a..6baf049 100644 (file)
@@ -31,8 +31,8 @@ var log = {
 };
 
 // Loggin handler that just writes to the global logger object
 };
 
 // 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() {
 };
 
 describe('Logging', function() {