Include timestamps in debug logs

This commit is contained in:
JC Brand 2017-10-25 17:09:35 +02:00
parent 05c3a5cad6
commit 4dad60c8d6
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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,