Expand description
§brk_logger
Tracing setup: colorized console output with local timestamps, plus optional daily log files.
With a directory, init also writes YYYY-MM-DD.txt (combined) and YYYY-MM-DD_<level>.txt
files into it. Each level admits at most 100 writes per second, so a chatty level cannot starve
the others; the combined file gets exactly the admitted writes. On startup, log files modified more
than seven days ago are removed.
Default filters turn off bitcoin, corepc, tracing, aide, fjall, lsm_tree and tower_http, and limit
rmcp to warnings. register_hook installs the process’s single hook, which receives every event
the filter admits.
The last 1,000 lines stay in memory: recent returns them, or those after a given line. Each line
has a seq counting the process’s lines from 0, so a reader asking again gets each line once, and
a jump in seq shows lines that left memory before it asked.
§Environment variables
LOG- log level (default:infoin release,debugin dev). Example:LOG=debug bitviewdRUST_LOG- comma-separatedtarget=leveldirectives with an optional default level; replacesLOGand every default filter
§Usage
use std::path::Path;
use tracing::info;
fn main() -> std::io::Result<()> {
brk_logger::init(Some(Path::new("logs")))?; // `None`: console only
info!("Ready");
Ok(())
}Structs§
Constants§
- LEVEL_
NAMES - Level names, as file suffixes and in log lines.
Functions§
- init
- Initialize the global tracing subscriber with a colorized console layer.
- init_
with_ default_ level - Initialize the logger with a caller-selected fallback level.
- log_
file_ date - The day of a file this writer produces,
YYYY-MM-DD.txt(combined) orYYYY-MM-DD_<level>.txt:Some("YYYY-MM-DD"),Nonefor any other name. - recent
- The kept lines from
from(aseq) on, or all of them; lines that left memory meanwhile are skipped, as the jump inseqshows. - register_
hook - Registers the process’s single hook, which receives every event the filter admits; errors if one is already registered.
- started
- When this process began its log.