Skip to main content

Module text_log

Module text_log 

Source
Expand description

A text log view on the data table: a line per entry, its time, entity, level and body, filtered by level and by text, following the tail, and tied to a time cursor.

Experimental: may change in any release (docs/stability.md).

Its design follows the text log view of the Rerun viewer (https://rerun.io, re_view_text_log, MIT OR Apache-2.0): the same four columns, the level in its colour (palette.log.*), the rows at the time cursor highlighted and brought into view when the cursor moves, a click on a row moving the time cursor to it. No Rerun code is used; the table is egui-pop’s DataTable (on Rerun’s egui_table).

  • Columns: the time, written in a timeline’s scale (TextLog::time_scale, or a bound timeline’s), else as a plain number; the entity path; the level as a coloured chip; the body, its first line, a multi-line body expanding to all its lines.
  • Filters: a toggle chip per level, each with its count, and a text filter matching the body or the entity path, case aside.
  • The tail: with Follow on (the default), the last line stays in view as lines come in; scrolled up, the view stays where it was, and scrolled back to the end it follows again.
  • The time cursor: the rows at the latest time not after the cursor (TextLog::time_cursor, or a bound timeline’s playhead, TextLog::timeline) are the table’s selection, drawn by the kit’s table-row; a click or the arrow keys move the cursor to a row’s time (TextLogOutput::cursor_moved; a bound timeline’s playhead is already there).
  • Large logs: only the rows in view are built, and the filter keeps its result between passes, scanning only the entries added since (a log grows at its end; TextLogState::refilter after anything else changed).

The application owns the entries (LogSource, in time order) and keeps a TextLogState.

use egui_pop_views::text_log::{Level, LogEntry, TextLog, TextLogState};

fn ui(ui: &mut egui::Ui, state: &mut TextLogState, log: &Vec<LogEntry>, now: &mut f64) {
    let out = TextLog::new("app.log", log)
        .label("Application log")
        .time_cursor(Some(*now))
        .show(ui, state);
    if let Some(t) = out.cursor_moved {
        *now = t;
    }
}

let log = vec![
    LogEntry::new(0.0, "/robot", Level::Info, "started"),
    LogEntry::new(1.5, "/robot/arm", Level::Warn, "joint 2 near its limit"),
];

Structs§

LogEntry
A log line, as an application may keep them (LogSource is implemented for a slice of them).
TextLog
The text log widget.
TextLogOutput
What TextLog::show returns.
TextLogState
A text log’s state between passes: its filters, Follow, the bodies expanded, the table’s own state and the filter’s result.

Enums§

Level
How severe a log line is, from trace to critical: the six levels of the palette.log.* tokens, in their order.

Traits§

LogSource
The entries a text log shows, in time order (an entry is never before the one ahead of it); the application owns them. Entries are named by their index, which stays theirs as the log grows at its end.

Functions§

format_time
How a time is written: in scale, else as a plain number (whole numbers without decimals: frame numbers).