television/television/logging.rs
Alexandre Pasmantier 63cb976027
refactor(ui): communicate ui state to tv using channels (#369)
The state of the UI is now synchronized with the `Television` struct
using a dedicated channel and is available at `Television.ui_state`.
This removes quite a bit of complexity from the existing code and should
allow for nicer implementations of features that need the UI state to
compute things in the background (typically knowing the target size of
an image you wish to construct in the background, as in #363)

The `UiState` currently only holds the UI layout:
```rs
pub struct UiState {
    pub layout: Layout,
}
```
2025-03-05 01:11:24 +01:00

24 lines
691 B
Rust

use anyhow::Result;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use crate::config::get_data_dir;
pub fn init() -> Result<()> {
let directory = get_data_dir();
std::fs::create_dir_all(directory.clone())?;
let log_path = directory.join(format!("{}.log", env!("CARGO_PKG_NAME")));
let log_file = std::fs::File::create(log_path)?;
let file_subscriber = fmt::layer()
.with_file(true)
.with_line_number(true)
.with_writer(log_file)
.with_target(false)
.with_ansi(false)
.with_filter(EnvFilter::from_default_env());
tracing_subscriber::registry()
.with(file_subscriber)
.try_init()?;
Ok(())
}