Files
Library/docs/agent-workflow/tasks/M-LOG-01-05.md

3.1 KiB

Log Hardening, Bounded Delivery, File Sync, and LogConfig Separation

Task ID: M-LOG-01..05 Phase: P2 Status: APPROVED Contracts: C-01, C-02, C-03, C-04, C-05, C-11

1. Context and baseline

Void::Log (Log.hpp + LogState/State.cpp) holds Sink behind State::mutex during emission, and Void::Logging::Logger (src/Log/Logger.cpp) uses an unbounded batch drain without byte budgeting, contiguous ticket completion, exception quarantine, or file durability/reopen controls, while Log links Configuration via FromConfig.hpp.

2. Deliverables

  • Split LogConfig (src/LogConfig/module.cmake, FromConfig.hpp/src/LogConfig/FromConfig.cpp) out of Log (src/Log/module.cmake: INTERNAL_DEPS Async Core Data Functional Memory Time LogState, OPTIONAL_DEPS Stacktrace, EXCLUDE_HEADERS Void/Log/Log.hpp Void/Log/FromConfig.hpp).
  • include/Void/Log/Log.hpp & src/LogState/State.cpp: immutable SinkRegistration, register_sink, detach_and_drain (DrainResult with would_deadlock), outer-of-lock callback invocation & owner destruction, reentrancy guard (depth <= 8) + emergency hook.
  • include/Void/Log/Entry.hpp: bool truncated{false};.
  • include/Void/Log/Logger.hpp & src/Log/Logger.cpp: LogErrorCode, make_log_error (kLogErrorDomain = 12), DeliveryLimits, FailurePolicy, LoggerOptions, SubmitState, Ticket, SubmitReceipt, FlushDurability, FlushOptions, CloseOptions, FlushReport, bounded deque with queued+in-flight entry and byte accounting, contiguous ticket watermark, try_submit, flush_through, close, quarantine & reset, admission-barrier set_mode, sync_files().
  • include/Void/Log/Sinks.hpp: CallbackLogger(Callback, LoggerOptions), MultiLogger::try_add with max 8 children and cycle check.
  • include/Void/Log/Formatter.hpp & src/Log/Formatter.cpp: field redaction in FieldFilter, LogfmtFormatter control-char escaping, JsonLinesFormatter int64 line numbers, format_bounded.
  • FileLogger / RotatingFileLogger / RollingFile: explicit create_directories, RotatingFileOptions::roadmap_defaults(), stream write-error surfacing, reopen(), POSIX ::fsync in sync_files().
  • src/LogConfig/FromConfig.cpp + moved tests/standalone/LogConfig/FromConfig.cpp: strict config value validation.
  • tests/standalone/Log/LogHardening.cpp and tests/package/LogOnly/{CMakeLists.txt,main.cpp} registered in tests/package/InstalledComponents.cmake.

3. Edge cases

  • Legacy 3-argument Logger constructor preserves compatibility for existing LogScopeSnapshot immediate recursion and AsyncLogger 400k stress test (owned_bytes >= max(8 MiB, entries * 1024), suppress_reentrancy = false).
  • DropOldest never evicts already-dispatched in-flight batch entries; Block rejects self-blocking on worker (would_deadlock).

4. Verification commands

dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w5-log -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOID_ENABLED_MODULES="Log;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w5-log && /tmp/void-w5-log/tests/VoidTests && ctest --test-dir /tmp/void-w5-log --output-on-failure --timeout 120'