Skip to content
  1. Docs
  2. enzUI framework
  3. Developers

Logging

Framework diagnostics through the log facade, their targets, the default logger, RUST_LOG, the systemd journal and your own logger.

enzUI reports what it notices through the log facade, never by printing: an icon name that does not exist, two controls with the same accessibility id, an actionable control with no name, a layout floor that cannot be met. Every message has a target under enzui::, so you can filter or route it like any other library's.

Targets

TargetWhat it reports
enzui::a11yAccessibility tree problems: duplicate ids, actionable nodes without an id or a name
enzui::iconIcon names missing from the registry (once per name)
enzui::layoutLayout floors the parent cannot honour
enzui::placementWindow sizes ignored as placeholders
enzui::chartChart data dropped for a reserved, empty or duplicate id
enzui::drag_dropDuplicate drag-and-drop collection ids
enzui::agentBackground tasks the agent integration refused
enzui::trace::*Opt-in traces, each turned on by its own environment variable (ENZUI_FRAME_COST, ENZUI_DIAGNOSTICS)

The default logger

enzui_widgets::app_setup::run installs a small logger before the event loop starts, unless the application installed one first. It prints LEVEL target: message lines to stderr and reads RUST_LOG:

sh
RUST_LOG=warn                     # every crate's warnings
RUST_LOG=info,enzui::a11y=off     # more detail, without accessibility warnings
RUST_LOG=enzui=debug              # everything enzUI says

Without RUST_LOG the filter is error,enzui=warn,enzui::trace=info: enzUI's warnings, other crates' errors only, and the opt-in traces once their variable is set. The longest matching target prefix decides, by whole path segments.

Apps that do not use app_setup::run call enzui_core::logging::init_default() themselves.

The systemd journal

When stderr already goes to the systemd journal (systemd says so in JOURNAL_STREAM), the default logger writes to the journal in its native protocol instead. Each record keeps its priority (error 3, warning 4, info 6, debug and trace 7), its target as LOG_TARGET, and its source as CODE_FILE, CODE_LINE and CODE_MODULE. The executable's name is the SYSLOG_IDENTIFIER. enzui_core::logging::init_journal("notes") sends to the journal whatever stderr is.

sh
journalctl --user -t notes                 # this application
journalctl --user -t notes -p warning      # warnings and errors only
journalctl --user -t notes LOG_TARGET=enzui::a11y

Your own logger

Install any log implementation before calling run and the default steps aside:

rust
fn main() -> iced::Result {
    env_logger::init(); // or tracing_subscriber with its log bridge
    enzui_widgets::app_setup::run(/* .. */)
}

With tracing, enable tracing-subscriber's tracing-log feature (or call tracing_log::LogTracer::init()) so log records become events.