diff options
author | Ben Langfeld <ben@langfeld.me> | 2015-03-24 18:15:11 +0300 |
---|---|---|
committer | Ben Langfeld <ben@langfeld.me> | 2015-03-24 18:15:11 +0300 |
commit | 952bfd0f3c24a529ad368a4c884ebcf3b3da24bf (patch) | |
tree | a8a1c533a8a4adbd92cc532a5ec4144b69f75634 | |
parent | 6869080bd7978385dc4604ca479b390917ca83f1 (diff) | |
parent | 04de8e97259d27f4329bf6ebbd8c366f56d22744 (diff) |
Merge pull request #381 from bklang/feature/warning_and_error_logging
Feature: warning and error logging
-rw-r--r-- | src/core.js | 16 | ||||
-rw-r--r-- | src/core/event.js | 2 | ||||
-rw-r--r-- | src/util.js | 3 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js index ad56181..a6f2fa8 100644 --- a/src/core.js +++ b/src/core.js @@ -508,5 +508,21 @@ Candy.Core = (function(self, Strophe, $) { */ self.log = function() {}; + /** Function: warn + * Print a message to the browser's "info" log + * Enabled regardless of debug mode + */ + self.warn = function() { + Function.prototype.apply.call(console.warn, console, arguments); + }; + + /** Function: error + * Print a message to the browser's "error" log + * Enabled regardless of debug mode + */ + self.error = function() { + Function.prototype.apply.call(console.error, console, arguments); + }; + return self; }(Candy.Core || {}, Strophe, jQuery)); diff --git a/src/core/event.js b/src/core/event.js index d3e8e60..48e18b0 100644 --- a/src/core/event.js +++ b/src/core/event.js @@ -98,7 +98,7 @@ Candy.Core.Event = (function(self, Strophe, $) { break; default: - Candy.Core.log('[Connection] What?!'); + Candy.Core.warn('[Connection] Unknown status received:', status); break; } /** Event: candy:core.chat.connection diff --git a/src/util.js b/src/util.js index 17a6469..d9810f7 100644 --- a/src/util.js +++ b/src/util.js @@ -629,8 +629,7 @@ Candy.Util = (function(self, $){ el.append(self.createHtml(elem.childNodes[i], maxLength, currentLength)); } } catch(e) { // invalid elements - Candy.Core.log("[Util:createHtml] Error while parsing XHTML:"); - Candy.Core.log(e); + Candy.Core.warn("[Util:createHtml] Error while parsing XHTML:", e); el = Strophe.xmlTextNode(''); } } else { |