You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/07/12 01:47:36 UTC

git commit: [CB-4181] console.log - logging objects show as [object Object]

Updated Branches:
  refs/heads/master 1e67667ca -> 1c8c456e4


[CB-4181] console.log - logging objects show as [object Object]


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-console/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-console/commit/1c8c456e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-console/tree/1c8c456e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-console/diff/1c8c456e

Branch: refs/heads/master
Commit: 1c8c456e457d42dfd79c92e28be9b6a1a6d022de
Parents: 1e67667
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Jul 11 16:47:27 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Jul 11 16:47:27 2013 -0700

----------------------------------------------------------------------
 www/logger.js | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-console/blob/1c8c456e/www/logger.js
----------------------------------------------------------------------
diff --git a/www/logger.js b/www/logger.js
index ebe4425..276cec4 100644
--- a/www/logger.js
+++ b/www/logger.js
@@ -195,6 +195,11 @@ function logWithArgs(level, args) {
     logger.logLevel.apply(logger, args);
 }
 
+// return the correct formatString for an object
+function formatStringForMessage(message) {
+    return (typeof message === "string") ? "" : "%o"; 
+}
+
 /**
  * Logs a message at the specified level.
  *
@@ -204,6 +209,7 @@ function logWithArgs(level, args) {
 logger.logLevel = function(level /* , ... */) {
     // format the message with the parameters
     var formatArgs = [].slice.call(arguments, 1);
+    formatArgs.unshift(formatStringForMessage(formatArgs[0])); // add formatString
     var message    = logger.format.apply(logger.format, formatArgs);
 
     if (LevelsMap[level] === null) {