Skip to content

Commit

Permalink
fix: do not use console from main window
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Sep 8, 2024
1 parent b0dcf4e commit ec2a58e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class BasicTool {
*/
protected _basicOptions: BasicOptions;

protected _console: Console;

/**
* @deprecated Use `patcherManager` instead.
*/
Expand Down Expand Up @@ -45,6 +47,12 @@ export class BasicTool {
_plugin: undefined,
},
};
let { ConsoleAPI } = Components.utils.import(
"resource://gre/modules/Console.jsm"
);
this._console = new ConsoleAPI({
consoleID: `${this._basicOptions.api.pluginID}-${Date.now()}`,
});
this.updateOptions(data);
return;
}
Expand Down Expand Up @@ -189,7 +197,6 @@ export class BasicTool {
return;
}
const Zotero = this.getGlobal("Zotero");
const console = this.getGlobal("console");
// If logOption is not provides, use the global one.
let options: typeof this._basicOptions.log;
if (data[data.length - 1]?._type === "toolkitlog") {
Expand All @@ -202,13 +209,9 @@ export class BasicTool {
data.splice(0, 0, options.prefix);
}
if (!options.disableConsole) {
if (!console) {
Services.console.logStringMessage(data.join("\n"));
} else {
console.groupCollapsed(...data);
console.trace();
console.groupEnd();
}
this._console.groupCollapsed(...data);
this._console.trace();
this._console.groupEnd();
}
if (!options.disableZLog) {
Zotero.debug(
Expand Down

0 comments on commit ec2a58e

Please sign in to comment.