jdxi_editor.ui.widgets.viewer.log

This module provides a graphical log viewer using PySide6. The LogViewer class is a QMainWindow-based widget that displays the log file written by Decologr. It automatically refreshes to show new log entries.

Classes:

  • LogViewer: A main window that displays the log file and refreshes automatically.

Features:

  • Dark theme with a modern red-accented styling, in fixed-width text so the columns line up; the emoji Decologr puts before each message are left out (the level column already says it).

  • Two tabs: every line, and the lines that deserve attention (warnings, errors and what follows them, e.g. a traceback).

  • Automatically reads and displays the log file written by Decologr. Each run writes a file named after the time it started, rotated at 1MB, so the file to read is taken from the installed log handler rather than from a fixed path (see resolve_log_file()).

  • Refreshes periodically to show new log entries, and follows the file across rotation. It reads bytes and holds a line still being written, so no line is broken or shown twice.

  • Provides a “Clear Log” button: the lines written from then on appear.

  • Auto-scrolls to the bottom to show the latest entries.

Usage Example:

>>> viewer = LogViewer()
>>> viewer.show()

Attributes

ATTENTION

_ENTRY

_EMOJI

MAX_LINES

Classes

LogViewer

Functions

log_directory() → pathlib.Path

Directory Decologr writes log files to.

resolve_log_file([log_dir]) → Optional[pathlib.Path]

The log file currently being written.

fixed_font() → PySide6.QtGui.QFont

A fixed-width font for the log lines.

clean(line) → str

The line without the emoji Decologr puts before each message.

needs_attention(lines[, following]) → tuple[list[str], bool]

The lines with a level from WARNING up, with the lines that continue them.

Module Contents

jdxi_editor.ui.widgets.viewer.log.ATTENTION = ('WARNING', 'ERROR', 'CRITICAL')[source]
jdxi_editor.ui.widgets.viewer.log._ENTRY[source]
jdxi_editor.ui.widgets.viewer.log._EMOJI[source]
jdxi_editor.ui.widgets.viewer.log.MAX_LINES = 20000[source]
jdxi_editor.ui.widgets.viewer.log.log_directory() → pathlib.Path[source]

Directory Decologr writes log files to.

Returns:

Path

jdxi_editor.ui.widgets.viewer.log.resolve_log_file(log_dir: pathlib.Path | None = None) → pathlib.Path | None[source]

The log file currently being written.

Decologr names each run’s file after the time it started (jdxi_editor-01Feb2026-10-32-09.log) and rotates it at 1MB, so there is no file at a fixed path to open. The handler installed by setup_logging knows the name, so it is asked first; failing that, the newest file in the log directory is used, preferring one that is not a rotated backup.

Parameters:

log_dir – Optional[Path] directory to search; defaults to log_directory()

Returns:

Optional[Path] the log file, or None if there is none

jdxi_editor.ui.widgets.viewer.log.fixed_font() → PySide6.QtGui.QFont[source]

A fixed-width font for the log lines.

jdxi_editor.ui.widgets.viewer.log.clean(line: str) → str[source]

The line without the emoji Decologr puts before each message.

jdxi_editor.ui.widgets.viewer.log.needs_attention(lines: list[str], following: bool = False) → tuple[list[str], bool][source]

The lines with a level from WARNING up, with the lines that continue them.

Parameters:
  • lines – list[str] log lines

  • following – bool the line before lines continued a warning or an error

Returns:

(the lines kept, whether the last line continues one)

class jdxi_editor.ui.widgets.viewer.log.LogViewer(midi_helper=None, parent=None)[source]

Bases: PySide6.QtWidgets.QMainWindow

log_file[source]
last_position = 0[source]
_partial = b''[source]
_following = False[source]
_attention_count = 0[source]
fast_refresh_mode = True[source]
tabs[source]
log_text[source]
attention_text[source]
refresh_mode_button[source]
refresh_timer[source]
_text_view() → PySide6.QtWidgets.QPlainTextEdit[source]
_update_attention_title() → None[source]
load_log_file()[source]

Read the whole file again.

_no_log_file_message() → str[source]

What to show when there is no log file to read.

Returns:

str

refresh_log_file()[source]

Append the complete lines written since the last read.

static _append(view: PySide6.QtWidgets.QPlainTextEdit, lines: list[str]) → None[source]
toggle_refresh_mode()[source]

Toggle between fast refresh (500ms) and slow refresh (30s)

clear_log()[source]

Empty the view; only the lines written from now on appear (the file is untouched).

closeEvent(event)[source]

Stop the refresh timer when window is closed