Updated logging to both file and console
This commit is contained in:
13
src-tauri/Cargo.lock
generated
13
src-tauri/Cargo.lock
generated
@@ -2274,6 +2274,15 @@ dependencies = [
|
||||
"syn 2.0.110",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.10"
|
||||
@@ -4977,10 +4986,14 @@ version = "0.3.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"regex-automata",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
@@ -36,7 +36,7 @@ sha2 = "0.10.9"
|
||||
base64 = "0.22.1"
|
||||
thiserror = "1"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
tracing-subscriber = { version = "0.3", features = ["registry", "fmt", "env-filter"] }
|
||||
once_cell = "1"
|
||||
flate2 = "1.0.28"
|
||||
rust_socketio = "0.6.0"
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
};
|
||||
use tauri::async_runtime;
|
||||
use tauri::Manager;
|
||||
use tracing_subscriber;
|
||||
use tracing_subscriber::{self, util::SubscriberInitExt};
|
||||
|
||||
static APP_HANDLE: std::sync::OnceLock<tauri::AppHandle<tauri::Wry>> = std::sync::OnceLock::new();
|
||||
|
||||
@@ -48,12 +48,31 @@ fn setup_fdoll() -> Result<(), tauri::Error> {
|
||||
let file_appender = tracing_appender::rolling::daily(&app_log_dir, "friendolls.log");
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
// Create a filter - adjust the level as needed (trace, debug, info, warn, error)
|
||||
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
|
||||
|
||||
// Create a layer that writes to the file
|
||||
let file_layer = tracing_subscriber::fmt::layer()
|
||||
.with_target(false)
|
||||
.with_thread_ids(false)
|
||||
.with_file(true)
|
||||
.with_line_number(true)
|
||||
.with_writer(non_blocking) // Log to file
|
||||
.with_writer(non_blocking);
|
||||
|
||||
// Create a layer that writes to stdout (console)
|
||||
let console_layer = tracing_subscriber::fmt::layer()
|
||||
.with_target(false)
|
||||
.with_thread_ids(false)
|
||||
.with_file(true)
|
||||
.with_line_number(true);
|
||||
|
||||
// Combine both layers with filter
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
tracing_subscriber::registry()
|
||||
.with(filter)
|
||||
.with(file_layer)
|
||||
.with(console_layer)
|
||||
.init();
|
||||
|
||||
state::init_fdoll_state(Some(_guard));
|
||||
|
||||
Reference in New Issue
Block a user