X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/335637478e6ee83862de720a2d85437a8b0bdf01..941d09019e402ac565101fba6d824bd48504c90b:/lib/cobalt.js?ds=sidebyside diff --git a/lib/cobalt.js b/lib/cobalt.js index 981aab2..f3effcd 100644 --- a/lib/cobalt.js +++ b/lib/cobalt.js @@ -91,26 +91,39 @@ // Builds a Cobalt Log Object buildLog : function (item, level) { - var co = this, oldItem; + var co = this, oldItem, logObject = {}; + + if (typeof item === "undefined" || item === null || !item._cobaltLog) { + logObject.message = item; + logObject._cobaltLog = true; + logObject._from = co.from; + logObject._level = level || 6; + logObject._levelString = co._levelString(logObject._level); + logObject._version = co.version; + logObject._timestamp = co.now(); + logObject._indentLevel = co.currentIndent; + logObject._color = co.currentColor; + logObject._separator = false; + return logObject; + } - if (!item._cobaltLog) { - if (typeof item !== "object") { - item = {message : item.toString() }; - } else { - item.message = Cobalt.stringify(item); - } + return 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; + extendLog : function (extendingObject) { + var co = this, logObject, + property; + + logObject = co.buildLog(undefined, 6); + extendingObject = extendingObject || {}; + + for (property in extendingObject) { + if (extendingObject.hasOwnProperty(property)) { + logObject[property] = extendingObject[property]; + } } - return item; + return logObject; }, buildSeparator : function (type) { @@ -239,7 +252,7 @@ // Returns the current time in microseconds. now : function () { - if (typeof performance !== 'undefined') { + if (typeof performance !== 'undefined' && performance.timing) { return performance.timing.navigationStart + performance.now(); }