mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1060161 - Add stack trace to console.assert,error,trace messages. r=janx
This commit is contained in:
parent
5345e91818
commit
789b89e789
@ -30,6 +30,12 @@ function log(msg) {
|
||||
//dump('ProcessGlobal: ' + msg + '\n');
|
||||
}
|
||||
|
||||
function formatStackFrame(aFrame) {
|
||||
let functionName = aFrame.functionName || '<anonymous>';
|
||||
return ' at ' + functionName +
|
||||
' (' + aFrame.filename + ':' + aFrame.lineNumber + ')';
|
||||
}
|
||||
|
||||
const gFactoryResetFile = "/persist/__post_reset_cmd__";
|
||||
|
||||
function ProcessGlobal() {}
|
||||
@ -112,11 +118,21 @@ ProcessGlobal.prototype = {
|
||||
// Pipe `console` log messages to the nsIConsoleService which
|
||||
// writes them to logcat on Gonk.
|
||||
let message = subject.wrappedJSObject;
|
||||
let prefix = ('Content JS ' + message.level.toUpperCase() +
|
||||
' at ' + message.filename + ':' + message.lineNumber +
|
||||
' in ' + (message.functionName || 'anonymous') + ': ');
|
||||
Services.console.logStringMessage(prefix + Array.join(message.arguments,
|
||||
' '));
|
||||
let args = message.arguments;
|
||||
let stackTrace = '';
|
||||
|
||||
if (message.level == 'assert' || message.level == 'error' || message.level == 'trace') {
|
||||
stackTrace = Array.map(message.stacktrace, formatStackFrame).join('\n');
|
||||
} else {
|
||||
stackTrace = formatStackFrame(message);
|
||||
}
|
||||
|
||||
if (stackTrace) {
|
||||
args.push('\n' + stackTrace);
|
||||
}
|
||||
|
||||
let prefix = 'Content JS ' + message.level.toUpperCase() + ': ';
|
||||
Services.console.logStringMessage(prefix + Array.join(args, ' '));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user