Skip to main content

tiny_dlna/
lib.rs

1//! A tiny DLNA sender (`tiny-cli`) and receiver (`tiny-render`).
2
3pub mod cli;
4pub mod config;
5pub mod net;
6pub mod render;
7pub mod ssdp;
8pub mod xml;
9
10use std::io::Write;
11
12use log::LevelFilter;
13
14pub const VERSION: &str = env!("CARGO_PKG_VERSION");
15
16/// Log target for per-request HTTP access lines.
17pub const HTTP_LOG: &str = "tiny_dlna::http";
18
19/// Set up logging: errors by default, with per-module overrides.
20pub fn init_logging(filters: &[(&str, LevelFilter)]) {
21    let mut builder = env_logger::Builder::new();
22    builder.filter_level(LevelFilter::Error);
23    for (module, level) in filters {
24        builder.filter_module(module, *level);
25    }
26    builder.format(|buf, record| {
27        writeln!(
28            buf,
29            "[{}][{}] {}",
30            chrono::Local::now().format("%Y-%m-%d %H:%M:%S,%3f"),
31            record.level(),
32            record.args()
33        )
34    });
35    builder.init();
36}