mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
Check that stack trace is available, fixes logging in browser
This commit is contained in:
@@ -69,13 +69,15 @@ Log.prototype.error = Log.makeLevel(4);
|
||||
*/
|
||||
|
||||
function getLogInfo(message, args) {
|
||||
var stack = new Error().stack;
|
||||
|
||||
return [
|
||||
// Timestamp
|
||||
'[' + new Date().toISOString() + ']',
|
||||
message,
|
||||
'--',
|
||||
// Location
|
||||
(new Error()).stack.split('\n')[4].replace(/^\s+/, ''),
|
||||
(typeof stack === 'string') ? stack.split('\n')[4].replace(/^\s+/, '') : '',
|
||||
'\n'
|
||||
].concat(args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user