Skip to main content

Module journal

Module journal 

Source
Expand description

The journal a problem report attaches: a time window of what the application did, redacted, and the bundle help.report shows before anything leaves the machine.

A Recorder follows the journal (AppHandle::events_since) once a pass and keeps the entries of the last few minutes (RecorderConfig::window, 5 by default): commands and their outcomes, refusals, facts, the application’s summary events. It keeps its own copy rather than reading the shared journal at report time: that journal is a ring of a fixed count, where a burst of frequent entries pushes the rare ones out; a time window keeps a rare entry as long as it is recent. Kinds that come at every pass or at a high rate are skipped (RecorderConfig::skip, patterns as the journal reads them: pop.pointer.*, *).

Each entry is redacted as it is kept (Redactor): a private command’s arguments, result and error read <private> (host::redact_private); every string has the home folder written ~, every other absolute path reduced to its root and its extension (/…/*.raw), and any secret of the environment blanked.

use std::time::Duration;
use egui_pop_api::about::journal::{Recorder, RecorderConfig, Redactor};
use egui_pop_api::host::Event;
use serde_json::json;
use web_time::Instant;

let redactor = Redactor::new(Some("/home/ann"), &[]);
let mut rec = Recorder::new(RecorderConfig::default().skip("view.frame"));
let t0 = Instant::now();
let event = |seq, name: &str, data| Event {
    seq, source: "user".into(), cause: None, name: name.into(), data,
};
rec.record(t0, &[
    event(1, "command.dispatched", json!({ "command": "file.open", "args": { "path": "/home/ann/Photos/a.raw" } })),
    event(2, "view.frame", json!(null)),
], &redactor);
let kept = rec.window(t0 + Duration::from_secs(1));
assert_eq!(kept.len(), 1);
assert_eq!(kept[0].data["args"]["path"], "~/….raw");
// Past the window, it goes.
assert!(rec.window(t0 + Duration::from_secs(301)).is_empty());

Structs§

Aliases
Ids replaced by aliases numbered in order of appearance (photo-1, photo-2…): the same id gets the same alias across a report, so entries still tie together, and an id that is a fingerprint (a content hash, an account id) never leaves the machine.
Bundle
What a problem report attaches: shown to the user before anything leaves the machine (Bundle::text).
Recorded
An entry of a report’s journal: a journal event, redacted, with its age when the report was made.
Recorder
The journal’s recent entries, kept by time.
RecorderConfig
What a recorder keeps and for how long.
Redactor
Hides what a report must not carry: private commands’ data, the home folder’s name, absolute paths, the environment’s secrets.

Constants§

CAP
The most entries a recorder keeps, whatever their age: a bound on its memory, far above what a few minutes of skipped-free use give.
SECRET
What stands for a secret in a report.
WINDOW
How long a report’s journal reaches back by default.

Functions§

bus_description
The bus’s points and the order of each one’s listeners, for a report (ids only: no input and no value).

Type Aliases§

AliasFn
Says whether a token (a run of letters and digits) is an id to alias.