diff --git a/electron/core/BeanFactory.ts b/electron/core/BeanFactory.ts index 01949ff..f3c0e83 100644 --- a/electron/core/BeanFactory.ts +++ b/electron/core/BeanFactory.ts @@ -11,13 +11,16 @@ class BeanFactory { return; } const instance = new (clazz as any)(); - this._beans.set(beanName, instance); } public static setBean(name: string, bean: T): void { this._beans.set(name, bean); - Logger.info(`register bean ${name} ${bean}`); + Logger.info( + `${this.name}.${arguments[0]}`, + `register bean ${name} ${bean}` + ); + // Logger.info(`register bean ${name} ${bean}`); } public static getBean(name: string): T { diff --git a/electron/core/Logger.ts b/electron/core/Logger.ts index fd4622b..7cc58ef 100644 --- a/electron/core/Logger.ts +++ b/electron/core/Logger.ts @@ -6,13 +6,21 @@ class Logger { log.transports.console.level = "debug"; } - static info(msg: string) {} + public static info(module: string, msg: string) { + log.info(`[${module}] ${msg}`); + } - static debug(msg: string) {} + public static debug(module: string, msg: string) { + log.debug(`[${module}] ${msg}`); + } - static warn(msg: string) {} + public static warn(module: string, msg: string) { + log.warn(`[${module}] ${msg}`); + } - static error(msg: string) {} + public static error(module: string, msg: string) { + log.warn(`[${module}] ${msg}`); + } } export default Logger; \ No newline at end of file diff --git a/electron/core/annotation/Logger.ts b/electron/core/annotation/Logger.ts new file mode 100644 index 0000000..d2f602d --- /dev/null +++ b/electron/core/annotation/Logger.ts @@ -0,0 +1,8 @@ +// export default function Logger(module?: string): ClassDecorator { +// return function (target: Object) { +// Object.defineProperty(target, "logger", { +// value: new (require("../LoggerFactory").default)(module), +// writable: true +// }); +// }; +// } diff --git a/electron/main/index.ts b/electron/main/index.ts index 0078b93..919879d 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -115,6 +115,10 @@ class FrpcDesktopApp { } return false; }); + Logger.info( + `FrpcDesktopApp.initializeWindow`, + `Window initialized.` + ); } initializeTray() { @@ -149,6 +153,10 @@ class FrpcDesktopApp { tray.on("double-click", () => { this._win.show(); }); + Logger.info( + `FrpcDesktopApp.initializeTray`, + `Tray initialized.` + ); } initializeElectronApp() { @@ -262,6 +270,11 @@ class FrpcDesktopApp { // todo stop frpc process this._quitting = true; }); + + Logger.info( + `FrpcDesktopApp.initializeElectronApp`, + `ElectronApp initialized.` + ); } initializeBeans() { @@ -334,6 +347,10 @@ class FrpcDesktopApp { "systemController", new SystemController(BeanFactory.getBean("systemService")) ); + Logger.info( + `FrpcDesktopApp.initializeBeans`, + `Beans initialized.` + ); } /** @@ -353,7 +370,10 @@ class FrpcDesktopApp { }; bean[method].call(bean, listenerParam); }); - Logger.info("initialize listeners success"); + Logger.info( + `FrpcDesktopApp.initializeListeners`, + `Listeners initialized.` + ); // this._beans.get("logService").watchFrpcLog(this._win); } @@ -377,9 +397,21 @@ class FrpcDesktopApp { const [beanName, method] = router.controller.split("."); const bean = BeanFactory.getBean(beanName); bean[method].call(bean, req); + Logger.debug( + `ipcRouter`, + `path: ${router.path} + req: (channel: ${ + req.channel + }, args: ${JSON.stringify( + req.args + )}) => bean: ${beanName}.${method}` + ); }); }); }); + Logger.info( + `FrpcDesktopApp.initializeRouters`, + `Routers initialized.` + ); } } diff --git a/vite.config.ts b/vite.config.ts index c8b26b9..60c7419 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,6 +23,13 @@ export default defineConfig(({ command }) => { const sourcemap = isServe || !!process.env.VSCODE_DEBUG; return { + css: { + preprocessorOptions: { + scss: { + api: "modern-compiler" + } + } + }, plugins: [ vue(), electron([