Skip to main content

Module logs

Module logs 

Source
Expand description

Logs to a file in the platform’s log directory, rotated by size, at a level the user sets.

Experimental: may change in any release (docs/stability.md).

Logs is a sink for the log facade (egui-pop and most crates log through it): each line goes to <dir>/<name>.log and to a tail kept in memory (what a crash report quotes). When the file passes its size, it becomes <name>.1.log (the older ones shift, the oldest beyond Logs::keep goes) and a new one starts.

LogsPlugin installs it as the process’s logger (the router is installed once; another plugin instance takes it over; with LogsPlugin::install off, it stays the app’s own), declares the developer.log_level setting (error, warn, info, debug, trace), the logs.reveal command (opens the folder) and the logs debug collector (the file, the level, the tail). An application on tracing or another logger feeds lines with Logs::write.

No step runs per line: a line is written from whatever thread logs it, and steps run on the interface thread. The crash report (crash) is where the logs reach the application’s hooks.

Owned rather than tracing-appender (MIT): it rotates by time, writes through tracing’s subscriber, and keeps no tail to quote; this is a hundred lines over std::fs.

use egui_pop_platform::logs::Logs;

let dir = std::env::temp_dir().join(format!("egui-pop-logs-doc-{}", std::process::id()));
let logs = Logs::new(&dir, "demo").max_size(200).keep(2);
for i in 0..20 {
    logs.write(log::Level::Info, "demo", &format!("line {i}"));
}
assert!(logs.tail().last().unwrap().ends_with("INFO  demo: line 19"));
assert!(dir.join("demo.1.log").exists());
assert!(!dir.join("demo.3.log").exists());

Structs§

Logs
A log file and its tail. Cheap to clone (shared).
LogsPlugin
Logs to a file, as a plugin (see the module).

Enums§

Level
An enum representing the available verbosity levels of the logger.
LevelFilter
An enum representing the available verbosity level filters of the logger.

Constants§

CMD_REVEAL
Opens the log folder.
LEVELS
The levels, as the setting stores them.
LOGS
The logs, as a service.
PLUGIN
The plugin’s id.
SETTING_LEVEL
The level written: error, warn, info, debug, trace.
TAIL
How many lines the tail keeps.

Functions§

installed
The logs the log facade writes to, when installed.
now
Now, as timestamp writes it (the browser’s clock on the web, where std::time::SystemTime::now panics).
parse_level
A level as the setting names it.
timestamp
2026-10-12T14:03:07.123Z for a time since the epoch.