feat: Add structured logging API with level filtering and component tags#170
Merged
Conversation
Replace all raw fprintf/printf diagnostic calls (21 sites across 14 source files) with cfd_log() structured logging. Adds DEBUG log level, global atomic log level filtering, extended callback with component info, and convenience macros (CFD_LOG_DEBUG/INFO/WARNING/ERROR). Backward-compatible: existing cfd_error/cfd_warning/cfd_info unchanged. ROADMAP 0.6 (Structured Logging & Diagnostics) complete.
The volatile pointer for s_global_callback_ex caused a TSan SEGV/DEADLYSIGNAL on Linux/Clang. Replace with cfd_atomic_ptr using _Atomic(void*) on POSIX and InterlockedExchangePointer on Windows to satisfy ThreadSanitizer's memory access checks.
_Atomic(void*) caused ThreadSanitizer SEGV (DEADLYSIGNAL) on Linux/Clang. Switch to _Atomic(uintptr_t) which is well-supported by TSan. Also fix double atomic load (TOCTOU) by loading callback pointer once into a local variable before use.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…ogging - Add <stdio.h> for snprintf declaration (needed under strict C99+ flags) - Clear s_ex_last_message when message is NULL to prevent stale state between tests
Plain volatile read doesn't guarantee atomicity on all Windows targets. Use ICXP(ptr, NULL, NULL) which returns the current value atomically.
Resilient to enum renumbering and self-documenting.
GCC/Clang will now warn on mismatched format strings at all CFD_LOG_* call sites.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…casts Out-of-range values (e.g., from int casts) could suppress ERROR logging or index out of bounds in the level name table.
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.
Replace all raw fprintf/printf diagnostic calls (21 sites across 14 source files) with cfd_log() structured logging. Adds DEBUG log level, global atomic log level filtering, extended callback with component info, and convenience macros (CFD_LOG_DEBUG/INFO/WARNING/ERROR).
Backward-compatible: existing cfd_error/cfd_warning/cfd_info unchanged.
ROADMAP 0.6 (Structured Logging & Diagnostics) complete.