Skip to content

feat(logging): add log clear API#117

Merged
NewYaroslav merged 2 commits into
mainfrom
feat/log-clear-api
Jun 2, 2026
Merged

feat(logging): add log clear API#117
NewYaroslav merged 2 commits into
mainfrom
feat/log-clear-api

Conversation

@NewYaroslav

Copy link
Copy Markdown
Owner

Summary

  • add backend-neutral LogClearOptions/LogClearResult and ILogger::clear_logs default unsupported implementation
  • add Logger::clear_logger and Logger::clear_all_loggers using strategy snapshots outside the global logger lock
  • add LOGIT_CLEAR_LOGGER/LOGIT_CLEAR_LOGGER_EX/LOGIT_CLEAR_ALL_LOGGERS/LOGIT_CLEAR_ALL_LOGGERS_EX macros
  • implement cleanup for MemoryLogger, MdbxLogger, FileLogger, and UniqueFileLogger
  • add clear API tests for memory, file, unique-file, unsupported backends, snapshot behavior, and MDBX session/payload semantics

Verification

  • cmake -S . -B build-clear -G "MinGW Makefiles" -DLOGIT_CPP_BUILD_TESTS=ON
  • cmake --build build-clear --target logger_clear_api_test -j2
  • ctest --test-dir build-clear -R logger_clear_api_test --output-on-failure
  • cmake -S . -B build-clear-mdbx -G "MinGW Makefiles" -DLOGIT_CPP_BUILD_TESTS=ON -DLOGIT_WITH_MDBX=ON -DLOGIT_USE_SUBMODULES=ON
  • cmake --build build-clear-mdbx --target mdbx_logger_test -j2
  • ctest --test-dir build-clear-mdbx -R mdbx_logger_test --output-on-failure
  • cmake -S . -B build-clear-cxx11 -G "MinGW Makefiles" -DLOGIT_CPP_BUILD_TESTS=ON -DCMAKE_CXX_STANDARD=11
  • cmake --build build-clear-cxx11 --target memory_logger_backend_test logger_clear_api_test -j2
  • git diff --check -- include/logit_cpp/logit/loggers/ILogger.hpp include/logit_cpp/logit/Logger.hpp include/logit_cpp/logit/log_macros.hpp include/logit_cpp/logit/loggers/MemoryLogger.hpp include/logit_cpp/logit/loggers/MdbxLogger.hpp include/logit_cpp/logit/loggers/FileLogger.hpp include/logit_cpp/logit/loggers/UniqueFileLogger.hpp tests/CMakeLists.txt tests/logger_clear_api_test.cpp tests/mdbx_logger_test.cpp

🤖 Generated with Claude Code

NewYaroslav and others added 2 commits June 1, 2026 16:49
Expose a backend-neutral cleanup path so applications can clear in-memory, MDBX, and file-backed logs without holding Logger's global strategy lock during backend cleanup.

Constraint: Preserve existing logger and macro APIs

Rejected: Separate ILogCleaner interface | adds dynamic-cast complexity without improving default unsupported behavior

Confidence: high

Scope-risk: moderate

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Create a fresh MDBX session when session metadata is cleared and make unsupported cleanup an explicit status instead of a message string convention.

Constraint: Preserve clear_logs compatibility and post-clear logging

Confidence: high

Scope-risk: narrow

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NewYaroslav NewYaroslav merged commit cc39962 into main Jun 2, 2026
13 checks passed
@NewYaroslav NewYaroslav deleted the feat/log-clear-api branch June 3, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant