withRecordedLogs

inline fun <T> withRecordedLogs(level: LogLevel = LogLevel.DEBUG, block: (RecordingLogSink) -> T): T

Routes KenworkLogger to a fresh RecordingLogSink at level for the duration of block, then restores the previous sink and level — even if block throws.

KenworkLogger is process-global, so avoid running tests that use this in parallel with other tests that log.