pacman-log 0.2.1

A Rust library for parsing and querying pacman logs
Documentation

pacman-log

A Rust library for parsing and querying pacman logs.

Usage

use pacman_log::{LogReader, Action, Result};

// Read system log
let entries: Vec<_> = LogReader::system()
    .filter_action(Action::Upgraded)
    .into_iter()
    .collect::<Result<Vec<_>>>()?;

// Reverse reading (most recent first)
let recent: Vec<_> = LogReader::open("/var/log/pacman.log")
    .reverse()
    .into_iter()
    .take(100)
    .collect::<Result<Vec<_>>>()?;

// Filter by package
let linux_history: Vec<_> = LogReader::system()
    .filter_package("linux")
    .into_iter()
    .collect::<Result<Vec<_>>>()?;

The iterator above yields package operations only. To see every line type (pacman commands, transaction markers, hook and scriptlet output) use entries, or group operations into commits with transactions:

use pacman_log::{LogReader, command_counts};

// Each transaction is 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
let counts = command_counts(LogReader::system().entries().filter_map(Result::ok));

License

GPL-3.0