Skip to main content

Module logger

Module logger 

Source
Expand description

log recording and reporting interface

Structs§

CapturedDiagnostics
Diagnostics captured from a worker thread by capture, for the main thread to fold back in via replay_captured. Carries both the already-formatted log text AND the REPORT count deltas — LOG_BUFFER and REPORT are BOTH #[thread_local], so forwarding only the text would still leave status_code blind to a worker’s failures.

Functions§

bind_log
Start capturing log output into the buffer (Perl: bind_log).
capture
Run f on the CURRENT (worker) thread with diagnostic capture. Binds a fresh thread-local log buffer for the duration so any Error!/Warn!/Info! f emits (directly or deep inside a conversion helper) is recorded instead of lost, and snapshots the worker’s REPORT counters afterward. The returned CapturedDiagnostics is replayed on the main thread by replay_captured after the worker is joined, so the messages reach the bound cortex.log and the failures register in status_code.
flush_log
Flush and return the captured log output, stopping capture (Perl: flush_log).
init
initialize the logger at a given verbosity level
mark_stderr_at_line_start
Tell the logger that stderr is back at line start. For the Note! / NoteLog! macros, which write to stderr directly via println_stderr! rather than through log::Log — without this the next diagnostic record could emit a spurious leading newline.
note_to_log
Append a progress note to the captured log (.latexml.log) only — the LOG half of Perl Note/NoteLog (Common/Error.pm: print $LOG _freshline($LOG), strip_ansi($message), "\n" if $LOG). ANSI is stripped and the note lands on its own fresh line with a single trailing newline, so CorTeX’s line-anchored parser and the .latexml.log stay clean (mirrors the diagnostic-record freshline path below). No-op when no buffer is bound or output is suppressed — unlike a log::info! record it is NOT gated on the stderr verbosity, because the log is the verbose record (Perl writes it regardless of $VERBOSITY).
replay_captured
Fold worker-thread diagnostics (from capture) into the main thread: append the captured log text to the bound LOG_BUFFER and merge the count deltas into the main REPORT. Call on the MAIN thread, in a deterministic order (e.g. worker/job order), after the workers join. The worker already echoed each line to the shared stderr fd in real time, so this does NOT re-print to stderr — it only repairs the captured log + status tally.