grievouz / egui_tracing

Integrates tracing and logging with egui for event collection/visualization
The Unlicense
26 stars 19 forks source link

feature request: serde json #33

Open oligamiq opened 3 days ago

oligamiq commented 3 days ago

Errors flood the system. I would like to save old logs to opfs, etc., so it would be great if you could add a serde function.

grievouz commented 3 days ago

Regarding your request for serde support, I plan to implement this feature within the next week.

To address your concern about saving old logs, you can currently add another layer to the registry to write logs simultaneously to a file or another destination such as a central logging server.

First, add the following dependency to your Cargo.toml:

tracing-subscriber = { version = "*", features = ["fmt"] }

Then, in your Rust code:

let collector = egui_tracing::EventCollector::default();
let debug_file = std::fs::OpenOptions::new()
    .append(true)
    .create(true)
    .open("log-debug.log")
    .unwrap();
let debug_file_layer = tracing_subscriber::fmt::layer()
    .with_ansi(false)
    .with_writer(debug_file);
tracing_subscriber::registry()
    .with(collector.clone())
    .with(debug_file_layer)
    .init();