Check that stack trace is available, fixes logging in browser

This commit is contained in:
wltsmrz
2015-03-27 15:49:13 -07:00
parent 949a1ca4ae
commit 53cae3a66d

View File

@@ -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);
}