]> git.r.bdr.sh - rbdr/cologne/commitdiff
Pass the objects directly to the console.
authorBen Beltran <redacted>
Wed, 22 May 2013 20:55:13 +0000 (15:55 -0500)
committerBen Beltran <redacted>
Wed, 22 May 2013 20:55:13 +0000 (15:55 -0500)
lib/cobalt.js
lib/loggers/console.js

index 17e694864606a70694840543ae9ab1ffa2f61c3e..d2d2c13c7fd37b79dc2e4fe4f6299b24f962c779 100644 (file)
 
       // Builds a Cobalt Log Object
       buildLog : function (item, level) {
-        var co = this, oldItem;
+        var co = this, oldItem, logObject = {};
 
         if (!item._cobaltLog) {
-          if (typeof item !== "object") {
-            item = {message : item.toString() };
-          } else {
-            item.message = Cobalt.stringify(item);
-          }
-
-          item._cobaltLog = true;
-          item._from = co.from;
-          item._level = item._level || level || 7;
-          item._levelString = co._levelString(item._level);
-          item._version = co.version;
-          item._timestamp = co.now();
-          item._indentLevel = co.currentIndent;
-          item._color = co.currentColor;
+          logObject.message = item;
+          logObject._cobaltLog = true;
+          logObject._from = co.from;
+          logObject._level = item._level || level || 7;
+          logObject._levelString = co._levelString(item._level);
+          logObject._version = co.version;
+          logObject._timestamp = co.now();
+          logObject._indentLevel = co.currentIndent;
+          logObject._color = co.currentColor;
+          return logObject;
         }
 
         return item;
index dc077c8858b1d6afa5b9d154896da6a2c0cb311e..e8f4d86f4cac8c45c7709b87dba3b81aef50eed8 100644 (file)
       },
 
       log : function () {
-        var i, messageArray = [], message, severity;
+        var i, message = [], severity;
 
         for (i = 0; i < arguments.length; i++) {
-          messageArray.push(this.format(arguments[i]));
+          // We're not formatting objects for now.
+
+          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:
-            this.console.error(message);
+            this.console.error.apply(this.console, message);
             break;
           case 4:
-            this.console.warn(message);
+            this.console.warn.apply(this.console, message);
             break;
           case 5:
           case 6:
-            this.console.info(message);
+            this.console.info.apply(this.console, message);
             break;
           case 7:
           default:
-            this.console.log(message);
+            this.console.log.apply(this.console, message);
             break;
         }
       },
@@ -74,7 +78,7 @@
           return this.formatter.format(logObject, this.formatterOpts);
         }
 
-        return logObject;
+        return logObject.message;
       }
     }
   });