Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit e2d2d39

Browse files
authored
Add timestamp to logs. (#414)
Timestamps make it easy to debug issues happen with specific call sequence.
1 parent 79ab6b4 commit e2d2d39

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/sdk/base/logger.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,23 @@ const Logger = (function() {
5454
NONE: NONE,
5555
};
5656

57-
that.log = window.console.log.bind(window.console);
57+
that.log = (...args) => {
58+
window.console.log((new Date()).toISOString(), ...args);
59+
};
5860

5961
const bindType = function(type) {
6062
if (typeof window.console[type] === 'function') {
61-
return window.console[type].bind(window.console);
63+
return (...args) => {
64+
window.console[type]((new Date()).toISOString(), ...args);
65+
};
6266
} else {
63-
return window.console.log.bind(window.console);
67+
return that.log;
6468
}
6569
};
6670

6771
const setLogLevel = function(level) {
6872
if (level <= DEBUG) {
69-
that.debug = bindType('log');
73+
that.debug = bindType('debug');
7074
} else {
7175
that.debug = noOp;
7276
}

0 commit comments

Comments
 (0)