Skip to main content

Module logs

Module logs 

Source
Expand description

Journal access for the log view.

Spawns journalctl as a one-shot subprocess with --output=json rather than linking sd-journal bindings: no libsystemd build dependency, and the JSON output carries PRIORITY reliably, which drives the coloring. Multi-line messages (scheduler Opts { ... } dumps and the like) are flattened into display lines here, with continuations marked so the UI can indent or fold them.

Re-exportsΒ§

use anyhow::Context; πŸ”’
use anyhow::Result; πŸ”’
use anyhow::bail; πŸ”’
use chrono::TimeZone; πŸ”’
use crate::system::system_command; πŸ”’

StructsΒ§

LogFetch
Result of one journal fetch: flattened display lines plus whether the tail limit cut the beginning off, so the UI can say so.
LogLine
One display line of the log view.

ConstantsΒ§

MAX_ENTRIES πŸ”’
Tail limit for a single journal fetch. Without it, a chatty scheduler on a long-running boot can hand back tens of megabytes of JSON, all parsed synchronously while the UI is frozen. The newest entries are what the view opens on anyway; anything older is journalctl’s job.
UNIT
The unit the log view inspects: the scheduler runs as its main process, so its stdout/stderr land in the unit’s journal.

FunctionsΒ§

fetch
Fetches the journal tail for unit (up to MAX_ENTRIES entries), current boot or the previous one, and flattens it into display lines (oldest first).
format_local_time πŸ”’
parse_entries πŸ”’
Pure parsing core: one journalctl --output=json line per entry in, flattened display lines out. Malformed entries are skipped rather than failing the whole view.