From 157dc097d18bb293d80450f6f97d07f93954be8e Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Sun, 25 Aug 2019 21:23:47 +0100 Subject: [PATCH] Clean up log output from determine-basal.js --- .../main/assets/OpenAPSAMA/loggerhelper.js | 25 +++++++++++++++++-- .../plugins/aps/openAPSMA/LoggerCallback.java | 8 +++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/src/main/assets/OpenAPSAMA/loggerhelper.js b/app/src/main/assets/OpenAPSAMA/loggerhelper.js index e790f465c8..81c19b5a38 100644 --- a/app/src/main/assets/OpenAPSAMA/loggerhelper.js +++ b/app/src/main/assets/OpenAPSAMA/loggerhelper.js @@ -1,12 +1,33 @@ var console = { }; console.error = function error(){ + var s = ''; for (var i = 0, len = arguments.length; i < len; i++) { - console2.log(arguments[i]); + if (i > 0) s = s + ' '; + if (typeof arguments[i] === 'undefined') { + s = s + 'undefined'; + } else if (typeof arguments[i] === 'object') { + s = s + JSON.stringify(arguments[i]); + } else { + s = s + arguments[i].toString(); + } } + s = s + "\n"; + console2.log(s); }; console.log = function log(){ + var s = ''; for (var i = 0, len = arguments.length; i < len; i++) { - console2.log(arguments[i]); + if (i > 0) s = s + ' '; + if (typeof arguments[i] === 'undefined') { + s = s + 'undefined'; + } else if (typeof arguments[i] === 'object') { + s = s + JSON.stringify(arguments[i]); + } else { + s = s + arguments[i].toString(); + } + //console2.log(arguments[i]); } + s = s + "\n"; + console2.log(s); }; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/LoggerCallback.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/LoggerCallback.java index 30ce388f5d..828da91a92 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/LoggerCallback.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/LoggerCallback.java @@ -36,16 +36,16 @@ public class LoggerCallback extends ScriptableObject { public void jsFunction_log(Object obj1) { if (L.isEnabled(L.APS)) - log.debug(obj1.toString()); + log.debug(obj1.toString().trim()); logBuffer.append(obj1.toString()); - logBuffer.append(' '); +// logBuffer.append(' '); } public void jsFunction_error(Object obj1) { if (L.isEnabled(L.APS)) - log.error(obj1.toString()); + log.error(obj1.toString().trim()); errorBuffer.append(obj1.toString()); - errorBuffer.append(' '); +// errorBuffer.append(' '); }