mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🔊 调试模式下的log不输出到文件
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! @file src/plugins.rs
|
||||
//! @desc 插件模块,用于注册插件
|
||||
//! @since Beta v0.4.3
|
||||
//! @since Beta v0.4.4
|
||||
|
||||
use super::utils;
|
||||
use log::LevelFilter;
|
||||
@@ -16,10 +16,17 @@ pub fn build_sql_plugin<R: Runtime>() -> TauriPlugin<R, Option<PluginConfig>> {
|
||||
|
||||
// 日志插件
|
||||
pub fn build_log_plugin<R: Runtime>() -> TauriPlugin<R> {
|
||||
tauri_plugin_log::Builder::default()
|
||||
if cfg!(debug_assertions) {
|
||||
return tauri_plugin_log::Builder::default()
|
||||
.targets([LogTarget::Stdout])
|
||||
.timezone_strategy(TimezoneStrategy::UseLocal)
|
||||
.level(LevelFilter::Debug)
|
||||
.build();
|
||||
}
|
||||
return tauri_plugin_log::Builder::default()
|
||||
.targets([LogTarget::LogDir, LogTarget::Stdout])
|
||||
.timezone_strategy(TimezoneStrategy::UseLocal)
|
||||
.level(LevelFilter::Info)
|
||||
.log_name(utils::get_current_date())
|
||||
.build()
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ async function getDeepLink(): Promise<UnlistenFn> {
|
||||
if (e.payload === "") return;
|
||||
// 导入格式: teyvatguide://import_uigf?app=appName
|
||||
// 跳转格式: localhost:4000/achievements/?app=appName
|
||||
// todo 后续更改路径&参数名称
|
||||
if (e.payload.startsWith("teyvatguide://import_uigf")) {
|
||||
const param = (<string>e.payload).split("teyvatguide://import_uigf/?")[1];
|
||||
let appName = "";
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
/**
|
||||
* @file utils/TGLogger.ts
|
||||
* @description 日志工具
|
||||
* @since Beta v0.4.2
|
||||
* @since Beta v0.4.4
|
||||
*/
|
||||
|
||||
import { info, warn, error } from "tauri-plugin-log-api";
|
||||
import { info, warn, error, attachConsole } from "tauri-plugin-log-api";
|
||||
|
||||
/**
|
||||
* @description 日志工具
|
||||
* @since Beta v0.4.2
|
||||
* @since Beta v0.4.4
|
||||
*/
|
||||
class TGLogger {
|
||||
constructor() {
|
||||
if (import.meta.env.MODE === "development") {
|
||||
void attachConsole().then(() => {
|
||||
console.log("Console attached");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 输出日志-信息
|
||||
* @since Beta v0.4.2
|
||||
|
||||
Reference in New Issue
Block a user