[Plugins] Move plugin-specific logger

This commit is contained in:
Beef 2023-02-19 22:29:25 +00:00
parent a13b6e210c
commit 6e75d64c05
3 changed files with 4 additions and 8 deletions

1
src/def.d.ts vendored
View file

@ -375,7 +375,6 @@ interface VendettaObject {
interface VendettaPluginObject {
manifest: PluginManifest;
storage: Indexable<any>;
logger: Logger;
}
declare global {

View file

@ -1,7 +1,7 @@
import { Logger } from "@types";
import { findByProps } from "@metro/filters";
const logModule = findByProps("setLogFn").default;
export const logModule = findByProps("setLogFn").default;
const logger: Logger = new logModule("Vendetta");
export default logger;

View file

@ -1,10 +1,7 @@
import { Indexable, PluginManifest, Plugin } from "@types";
import { awaitSyncWrapper, createMMKVBackend, createStorage, wrapSync } from "@lib/storage";
import { findByProps } from "@metro/filters";
import logger, { logModule } from "@lib/logger";
import safeFetch from "@utils/safeFetch";
import logger from "@lib/logger";
const logModule = findByProps("setLogFn").default;
type EvaledPlugin = {
onLoad?(): void;
@ -63,8 +60,8 @@ export async function evalPlugin(plugin: Plugin) {
manifest: plugin.manifest,
// Wrapping this with wrapSync is NOT an option.
storage: await createStorage<Indexable<any>>(createMMKVBackend(plugin.id)),
logger: new logModule(plugin.manifest.name),
}
},
logger: new logModule(`Vendetta » ${plugin.manifest.name}`),
};
const pluginString = `vendetta=>{return ${plugin.js}}\n//# sourceURL=${plugin.id}`;