Files
war-in-tunnels/src/logs.rs
T
GarandPLG 73f544d5d6
Nix package / build (push) Successful in 8m44s
Linux package builds (test) / linux (push) Successful in 2m25s
Linux package builds (test) / aur (push) Successful in 7m41s
Rust checks / check (push) Successful in 3m39s
Update formatting to use 4‑space indentation
- Adjust rustfmt.toml to set tab_spaces = 4.
- Reformat imports, struct definitions, function bodies, and match arms
  across the project to match the new style (aligned fields, added
  spacing, etc.).
- Ensure all code complies with the updated rustfmt settings.
2026-10-19 17:43:43 +02:00

38 lines
1.1 KiB
Rust

use simplelog::{Config, LevelFilter, WriteLogger};
use std::fs::File;
/// Initializes the global logger for the application.
///
/// This function creates (or truncates) a file called `war_in_tunnels.log`
/// in the current working directory and configures a `simplelog::WriteLogger`
/// to write log messages with a minimum level of `Info`.
///
/// # Panics
///
/// - If the log file cannot be created (e.g., due to permission issues).
/// - If the logger cannot be initialized (which would indicate an internal
/// error in the `simplelog` crate).
///
/// Call this once, preferably at the very beginning of `main()`, before any
/// logging macros are used.
///
/// # Example
///
/// ```
/// use war_in_tunnels::logs::init_logger;
/// use log::info;
///
/// fn main() {
/// init_logger();
/// info!("Application started");
/// }
/// ```
pub fn init_logger() {
WriteLogger::init(
LevelFilter::Info,
Config::default(),
File::create("war_in_tunnels.log").expect("Failed to create log file"),
)
.expect("Failed to initialize logger");
}