From 00f111498d8ed01cae348367e675bc021b64ea3e Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 25 Oct 2017 17:09:35 +0200 Subject: [PATCH] Include timestamps in debug logs --- CHANGES.md | 1 + src/converse-core.js | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c3969d04e..21bd3362d 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ ### Bugfixes - Don't require `auto_login` to be `true` when using the API to log in. +- Moment locale wasn't being set to the value passed via the `i18n` option. ### New Features - #828 Add routing for the `#converse-login` and `#converse-register` URL diff --git a/src/converse-core.js b/src/converse-core.js index df3b0d812..abff1df8a 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -155,27 +155,35 @@ }, console); if (level === Strophe.LogLevel.ERROR) { if (_converse.debug) { - logger.trace(`ERROR: ${message}`); + logger.trace(`${moment().format()} ERROR: ${message}`); } else { logger.error(`ERROR: ${message}`); } } else if (level === Strophe.LogLevel.WARN) { - logger.warn(`WARNING: ${message}`); + if (_converse.debug) { + logger.warn(`${moment().format()} WARNING: ${message}`); + } else { + logger.warn(`WARNING: ${message}`); + } } else if (level === Strophe.LogLevel.FATAL) { if (_converse.debug) { - logger.trace(`FATAL: ${message}`); + logger.trace(`${moment().format()} FATAL: ${message}`); } else { logger.error(`FATAL: ${message}`); } } else if (_converse.debug) { if (level === Strophe.LogLevel.DEBUG) { - logger.debug(`DEBUG: ${message}`); + logger.debug(`${moment().format()} DEBUG: ${message}`); } else { - logger.info(`INFO: ${message}`); + logger.info(`${moment().format()} INFO: ${message}`); } } }; + Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); }; + Strophe.error = function (msg) { _converse.log(msg, Strophe.LogLevel.ERROR); }; + + _converse.__ = function (str) { /* Translate the given string based on the current locale. * @@ -250,10 +258,6 @@ unloadevent = 'unload'; } - // Logging - Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); }; - Strophe.error = function (msg) { _converse.log(msg, Strophe.LogLevel.ERROR); }; - // Instance level constants this.TIMEOUTS = { // Set as module attr so that we can override in tests. 'PAUSED': 10000,