[codex] Add MemoryLogger subscriber callbacks#119
Merged
Conversation
Implement ILogSubscriber support for MemoryLogger so it can share live record callbacks with MdbxLogger through the common stored-log API. Callbacks receive LogRecordView snapshots after records are written and outside the backend mutex. Update MemoryLogger and MdbxLogger examples to demonstrate LOGIT_READ_* and LOGIT_*_LOG_CALLBACK macros, document the shared reader/subscriber contract, and add focused callback/thread-safety coverage.
MSVC does not allow the writer lambda in memory_logger_callback_test to use logs_per_writer unless it is explicitly captured. Capture the loop bound by value so the Windows build compiles while preserving the thread-safety test semantics.
Document how agents should account for the CI toolchain matrix, minimum CMake and C++ versions, sanitizer and timing-sensitive tests, and real-log CI failure triage. Link the new playbook from AGENTS.md and the guides index so future build, test, and CI changes have a focused checklist.
Replace the misleading LogRecordView name with LogRecordSnapshot without keeping an alias, making the owning snapshot semantics explicit in the public API and docs. Document subscriber callback ordering and removal semantics, make MdbxLogger callback dispatch deterministic by registration id, and add MDBX callback ordering coverage.
Explain why MemoryLogger captures the owning LogRecordSnapshot before moving the entry into the buffer while still dispatching callbacks only after the buffer update completes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ILogSubscribersupport toMemoryLogger, including add/remove callback registration and post-writeLogRecordViewnotification outside the backend mutex.MemoryLoggerand register the new test in CMake.ILogReader/ILogSubscribermacro API for fallback-friendly stored-log access.guides/ci.mdand link it from the agent guide index so future AI-agent changes account for CI toolchain parity, sanitizer/timing tests, and log-based CI triage.Why
MemoryLoggercan now be used as a functional fallback forMdbxLoggerin code that consumes stored logs throughLOGIT_READ_*and live updates throughLOGIT_ADD_LOG_CALLBACK/LOGIT_REMOVE_LOG_CALLBACK.The added agent guidance captures the Windows/MSVC failure mode found during CI and turns it into a reusable checklist for future generated changes.
Validation
ctest --test-dir build-mingw -R memory_logger_callback_test --output-on-failurectest --test-dir build-mingw -R "(memory_logger_backend_test|memory_logger_concurrency_test|memory_logger_integration_test|include_memory_logger_nhr_test)$" --output-on-failurectest --test-dir build-mingw -R "(include_loggers_nhr_test|include_quickstart_test|logger_snapshot_read_path_test|logger_clear_api_test)$" --output-on-failureexample_logit_memory_logger.example_logit_mdbx_loggerwithLOGIT_WITH_MDBX=OFFand withLOGIT_WITH_MDBX=ONusing bundled MDBX submodules.git diff --checkNote: MDBX example build emits a dependency warning from
mdbx-containersabout deprecatedstd::wstring_convert; it is unrelated to this change.