Summary
Consolidate multiple LOG_DEBUG macro definitions into a single implementation to eliminate preprocessor duplication.
Background (Why)
LOG_DEBUG macro is defined 4 times with minor variations
Different definitions for debug/release builds and logger name variants
Increases maintenance complexity and risk of inconsistency
Preprocessor duplication is hard to detect and maintain
Scope (What)
Current State (Duplicated Definitions)
File : include/kcenon/common/logging/log_macros.h
Line
Definition
Variant
57
LOG_DEBUG(msg)
With default logger
111
LOG_DEBUG(logger, msg)
With named logger
270-273
LOG_DEBUG(msg)
Release build (no-op)
```cpp
// Line 57: Debug build, default logger
#define LOG_DEBUG(msg)
LOG_IMPL(kcenon::common::interfaces::log_level::debug, msg)
// Line 111: Debug build, named logger
#define LOG_DEBUG(logger_name, msg)
LOG_IMPL_NAMED(logger_name, kcenon::common::interfaces::log_level::debug, msg)
// Lines 270-273: Release build
#ifdef NDEBUG
#define LOG_DEBUG(msg) ((void)0)
#endif
```
Proposed State
```cpp
// Single variadic macro handling all cases
#ifdef NDEBUG
#define LOG_DEBUG(...) ((void)0)
#else
#define LOG_DEBUG(...) LOG_DEBUG_IMPL(VA_ARGS )
// Use variadic dispatch
#define LOG_DEBUG_IMPL(...) \
LOG_DEBUG_DISPATCH(LOG_DEBUG_NARG(__VA_ARGS__), __VA_ARGS__)
#define LOG_DEBUG_1(msg) \
LOG_IMPL(kcenon::common::interfaces::log_level::debug, msg)
#define LOG_DEBUG_2(logger, msg) \
LOG_IMPL_NAMED(logger, kcenon::common::interfaces::log_level::debug, msg)
#endif
```
Impact Analysis (Where)
File : include/kcenon/common/logging/log_macros.h
Lines affected : 57, 111, 270-273
Duplicated code : ~15 lines
Risk : Low - macro consolidation with same behavior
Implementation Plan (How)
Create variadic macro dispatch mechanism
Consolidate LOG_DEBUG definitions
Apply same pattern to LOG_TRACE, LOG_INFO, LOG_WARNING, LOG_ERROR
Verify all existing usages compile correctly
Run full test suite
Update macro documentation
Acceptance Criteria
Labels
refactor
code-quality
duplication
Summary
Consolidate multiple LOG_DEBUG macro definitions into a single implementation to eliminate preprocessor duplication.
Background (Why)
Scope (What)
Current State (Duplicated Definitions)
File:
include/kcenon/common/logging/log_macros.hLOG_DEBUG(msg)LOG_DEBUG(logger, msg)LOG_DEBUG(msg)```cpp
// Line 57: Debug build, default logger
#define LOG_DEBUG(msg)
LOG_IMPL(kcenon::common::interfaces::log_level::debug, msg)
// Line 111: Debug build, named logger
#define LOG_DEBUG(logger_name, msg)
LOG_IMPL_NAMED(logger_name, kcenon::common::interfaces::log_level::debug, msg)
// Lines 270-273: Release build
#ifdef NDEBUG
#define LOG_DEBUG(msg) ((void)0)
#endif
```
Proposed State
```cpp
// Single variadic macro handling all cases
#ifdef NDEBUG
#define LOG_DEBUG(...) ((void)0)
#else
#define LOG_DEBUG(...) LOG_DEBUG_IMPL(VA_ARGS)
#endif
```
Impact Analysis (Where)
include/kcenon/common/logging/log_macros.hImplementation Plan (How)
Acceptance Criteria
Labels
refactorcode-qualityduplication