Merge pull request #317 from ripple/fix-browser-log

Check that Error.stack is available, fixes logging in browser
This commit is contained in:
Geert Weening
2015-03-27 16:52:18 -07:00

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