Skip to main content

Crate pacman_log

Crate pacman_log 

Source
Expand description

A Rust library for parsing and querying pacman logs.

LogReader iterates package operations (LogEntry); LogReader::entries yields every line type (Entry) including pacman commands and transaction markers, and LogReader::transactions groups operations into commits.

§Package operations

use pacman_log::{LogReader, Action};

// Read recent upgrades
let upgrades: Vec<_> = LogReader::system()
    .filter_action(Action::Upgraded)
    .into_iter()
    .take(10)
    .collect();

// Read from end of file (most recent first)
let recent: Vec<_> = LogReader::system()
    .reverse()
    .into_iter()
    .take(100)
    .collect();

// Parse a single line
let entry = pacman_log::parse_line(
    "[2024-01-15T10:30:45+0100] [ALPM] installed neovim (0.9.4-1)"
);

§Transactions and commands

use pacman_log::{LogReader, command_counts};

// Each commit, tagged with the pacman command that triggered it
for txn in LogReader::system().transactions().filter_map(Result::ok) {
    println!("{:?}: {} operations", txn.command, txn.operations.len());
}

// Most-run commands across the whole log
let counts = command_counts(LogReader::system().entries().filter_map(Result::ok));

Structs§

Entry
A parsed log line of any kind, not just package operations.
LogEntry
LogReader
Transaction
A single pacman commit: the operations applied between a transaction started and transaction completed marker.

Enums§

Action
Caller
The component that emitted a log line, taken from the second bracketed field.
Event
What a log line represents.

Constants§

DEFAULT_LOG_PATH

Functions§

command_counts
Tally how often each pacman command was run across a stream of entries.
parse_entry
Parse any pacman log line into an Entry, not just package operations.
parse_line
Parse a single pacman log line into a LogEntry.

Type Aliases§

Error
Result