| « Gmail の設定で Always use https を有効にすると Gmail Notifier で新着チェック不可 | Firefox 3.1 の新しいドラッグ&ドロップ API の基本的な使い方 (その1~イベントハンドラの追加) » |
nsIConsoleService
// サービス取得
var consoleSvc = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
// エラーコンソールへの出力内容を消去
consoleSvc.reset();
// #1 Components.utils.reportErrorによるのエラーメッセージ出力
Components.utils.reportError("error #1");
// #2 nsIConsoleService.logStringMessageによるエラーメッセージ出力
consoleSvc.logStringMessage("error #2");
// #3 nsIConsoleService.logMessageによるエラーメッセージ出力
var err = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
err.init("error #3", null, null, null, null, err.errorFlag, null);
consoleSvc.logMessage(err);
// エラーコンソールへの出力内容を列挙
var msgs = {};
consoleSvc.getMessageArray(msgs, {});
msgs.value.forEach(function(msg) {
dump("---
");
if (msg instanceof Ci.nsIScriptError) {
// [JavaScript Error]
msg.QueryInterface(Ci.nsIScriptError);
dump(
msg + "
" +
"errorMessage => " + msg.errorMessage + "
" +
"sourceName => " + msg.sourceName + "
" +
"sourceLine => " + msg.sourceLine + "
" +
"lineNumber => " + msg.lineNumber + "
" +
"columnNumber => " + msg.columnNumber + "
" +
"flags => " + msg.flags + "
" +
"category => " + msg.category + "
"
);
}
else {
// [xpconnect wrapped nsIConsoleMessage]
dump(
msg + "
" +
"message => " + msg.message + "
"
);
}
});
リファレンス
nsIConsoleService – MDC
nsIConsoleService.idl
nsIConsoleMessage.idl
nsIScriptError.idl