]> git.r.bdr.sh - rbdr/cologne/blobdiff - lib/loggers/console.js
Properly handle logging null.
[rbdr/cologne] / lib / loggers / console.js
index 50025022a97f8b087c34ddca80e02b7534c6d301..c8e3036bc8497ca44d8a5abaf592bdbe348b4c22 100644 (file)
             logger[property] = config[property];
           }
         }
             logger[property] = config[property];
           }
         }
+
+        if (!logger.console) {
+          logger.console = console;
+        }
       },
 
       log : function () {
       },
 
       log : function () {
-        var i, messageArray = [], message, severity;
+        var i, message = [], severity;
 
         for (i = 0; i < arguments.length; i++) {
 
         for (i = 0; i < arguments.length; i++) {
-          messageArray.push(this.format(arguments[i]));
-          if (!severity) {
-            severity = arguments[i]._level
+          // We're not formatting objects for now.
+
+          if (!arguments[i].__skipConsole && !arguments[i].message.__skipConsole) {
+            if (typeof arguments[i].message === 'object') {
+              message.push(arguments[i].message);
+            } else {
+              message.push(this.format(arguments[i]));
+            }
+            if (!severity) {
+              severity = arguments[i]._level
+            }
           }
         }
 
           }
         }
 
-        message = messageArray.join(' ');
-
         switch (severity){
           case 0:
           case 1:
           case 2:
           case 3:
         switch (severity){
           case 0:
           case 1:
           case 2:
           case 3:
-            this.console.error(message);
+            this.console.error.apply(this.console, message);
             break;
           case 4:
             break;
           case 4:
-            this.console.warn(message);
+            this.console.warn.apply(this.console, message);
             break;
           case 5:
           case 6:
             break;
           case 5:
           case 6:
-            this.console.info(message);
+            this.console.info.apply(this.console, message);
             break;
           case 7:
           default:
             break;
           case 7:
           default:
-            this.console.log(message);
+            this.console.log.apply(this.console, message);
             break;
         }
       },
             break;
         }
       },
@@ -70,7 +80,7 @@
           return this.formatter.format(logObject, this.formatterOpts);
         }
 
           return this.formatter.format(logObject, this.formatterOpts);
         }
 
-        return logObject;
+        return logObject.message;
       }
     }
   });
       }
     }
   });