From fcb01e83b2317f36e7357337969281dadb2722f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Wed, 8 Jan 2025 12:05:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Improve=20the=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/local.ts | 2 +- electron/main/index.ts | 3 ++- electron/utils/log.ts | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/electron/api/local.ts b/electron/api/local.ts index bad5b83..65de874 100644 --- a/electron/api/local.ts +++ b/electron/api/local.ts @@ -1,5 +1,5 @@ import {ipcMain} from "electron"; -import { logDebug, logError, logInfo, LogModule, logWarn } from "electron/utils/log"; +import { logDebug, logError, logInfo, LogModule, logWarn } from "../utils/log"; const {exec, spawn} = require("child_process"); diff --git a/electron/main/index.ts b/electron/main/index.ts index af23442..7a70f18 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -23,7 +23,7 @@ import { initFileApi } from "../api/file"; import { getConfig } from "../storage/config"; import { initCommonApi } from "../api/common"; import { initLocalApi } from "../api/local"; -import { logError, logInfo, LogModule } from "../utils/log"; +import { initLog, logError, logInfo, LogModule } from "../utils/log"; import { maskSensitiveData } from "../utils/desensitize"; process.env.DIST_ELECTRON = join(__dirname, ".."); @@ -155,6 +155,7 @@ export const createTray = (config: FrpConfig) => { logInfo(LogModule.APP, `Tray created successfully.`); }; app.whenReady().then(() => { + initLog(); logInfo( LogModule.APP, `Application started. Current system architecture: ${ diff --git a/electron/utils/log.ts b/electron/utils/log.ts index b72df27..7e3730a 100644 --- a/electron/utils/log.ts +++ b/electron/utils/log.ts @@ -5,12 +5,13 @@ export enum LogModule { FRP_CLIENT = "frpc client", LOGGER = "logger", GITHUB = "github", - STORAGE = "", + STORAGE = "" } -// 设置日志级别 -log.transports.file.level = "debug"; // 可以根据需要调整日志级别 -log.transports.console.level = "debug"; // 控制台输出日志级别 +export const initLog = () => { + log.transports.file.level = "debug"; + log.transports.console.level = "debug"; +}; // 自定义日志输出函数,记录到指定业务模块 export const logInfo = (module: LogModule, message: string) => {