Skip to content

Prototype logging macro API split#824

Draft
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:logging-macro-design-prototype
Draft

Prototype logging macro API split#824
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:logging-macro-design-prototype

Conversation

@wgtmac

@wgtmac wgtmac commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

This is a prototype for the logging macro API shape discussed in #725.

It demonstrates a possible end state:

  • keep logger.h focused on the C++ logging API;
  • move Iceberg-prefixed macros to log_macros.h;
  • put short LOG_* aliases behind an explicit opt-in header;
  • use preprocessor active-level gating so disabled fixed-level logs are fully compiled out;
  • centralize formatting, fallback, runtime filtering, and fatal handling in shared helpers.

This is meant as a design reference, not a replacement for #725.

Test Plan

  • .venv/bin/pre-commit run clang-format --files src/iceberg/logging/log_macros.h src/iceberg/logging/short_log_macros.h src/iceberg/logging/logger.h src/iceberg/test/log_macros_header_test.cc src/iceberg/test/log_macros_active_level_test.cc src/iceberg/test/log_macros_test.cc
  • .venv/bin/pre-commit run cmake-format --files src/iceberg/CMakeLists.txt src/iceberg/test/CMakeLists.txt
  • .venv/bin/pre-commit run meson-fmt --files meson.build src/iceberg/logging/meson.build src/iceberg/test/meson.build
  • ninja -C builddir src/iceberg/test/logging_test
  • ./builddir/src/iceberg/test/logging_test
  • cmake --build build --target logging_test
  • ./build/src/iceberg/test/logging_test

kamcheungting-db added a commit to kamcheungting-db/iceberg-cpp that referenced this pull request Jul 16, 2026
Adopt the structure from the apache#824 prototype (keeping our if constexpr gating):
- logger.h is now the C++ API only; ICEBERG_LOG_* macros move to log_macros.h,
  and the bare LOG_* aliases move behind an opt-in short_log_macros.h (replacing
  the ICEBERG_LOG_SHORT_MACROS define).
- Dedup the five macro bodies onto shared internal helpers (EmitIfEnabled +
  LogToCurrent / LogToCurrentRuntime / LogToExplicitRuntime / LogFatal) that take
  a lazy [&]()->std::string message thunk invoked only past ShouldLog, so disabled
  logs still don't evaluate their args. Keeps catch(...), the GetCurrentLogger()
  fatal path, and if constexpr compile-time floor.
- VFormat moves to log_macros.h (only ICEBERG_LOG_RUNTIME_FMT uses it).

Co-authored-by: Isaac
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