mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
fix(logging): log file growing indefinitely
Log files are now created on a daily rotation, keeping 3 days worth of logs. This also changes the log file names. Fixes #453
This commit is contained in:
parent
584300afd4
commit
f68d95a740
1 changed files with 8 additions and 1 deletions
|
@ -4,6 +4,7 @@ use std::{env, panic};
|
|||
use strip_ansi_escapes::Writer;
|
||||
use tracing::error;
|
||||
use tracing_appender::non_blocking::{NonBlocking, WorkerGuard};
|
||||
use tracing_appender::rolling::Rotation;
|
||||
use tracing_error::ErrorLayer;
|
||||
use tracing_subscriber::fmt::{Layer, MakeWriter};
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
@ -67,7 +68,13 @@ fn install_tracing() -> Result<WorkerGuard> {
|
|||
|
||||
let log_path = data_dir().unwrap_or(env::current_dir()?).join("ironbar");
|
||||
|
||||
let appender = tracing_appender::rolling::never(log_path, "error.log");
|
||||
let appender = tracing_appender::rolling::Builder::new()
|
||||
.rotation(Rotation::DAILY)
|
||||
.filename_prefix("ironbar")
|
||||
.filename_suffix("log")
|
||||
.max_log_files(3)
|
||||
.build(log_path)?;
|
||||
|
||||
let (file_writer, guard) = tracing_appender::non_blocking(appender);
|
||||
|
||||
tracing_subscriber::registry()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue