parse_json_log_line (src/journal.rs)

systemctl-tui · crates/systemctl-ui-core/src/journal.rs · rust · MIT
infra, Infra / DevOps

Parses journalctl JSON log lines into structured entries for display.

// Source: https://github.com/rgwood/systemctl-tui | License: MIT | Copyright 2023 Reilly Wood
// Provided via justclaw.it.com; keep this notice with the code.
//! Parsing of `journalctl --output=json` lines into structured log entries.
//!
//! We use JSON output (rather than `short-iso`) so we get the `PRIORITY` field, which
//! lets us colorize errors/warnings the way `journalctl` does in a terminal.

use chrono::{Local, TimeZone};
use serde_json::Value;

/// One displayable log line. Multi-line journal messages are split into multiple
/// entries (continuation lines have no timestamp).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LogEntry {
  /// Local time, pre-formatted for display ("2026-07-15 10:04"). `None` for
  /// continuation lines and non-journal messages (diagnostics, er

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key