feat: dependency-free leveled logging facility#18
Merged
Conversation
Replace ad-hoc std::cout/std::cerr/printf output across the engine with a small, dependency-free leveled logger (include/ncorr/log.h, src/log.cpp). - Five severity levels (TRACE/DEBUG/INFO/WARN/ERROR) plus OFF, with independent console and log-file thresholds. - Thread-safe (mutex), safe under the OpenMP parallel DIC regions. - Stream-style macros (NLOG_INFO << ...) that short-circuit message construction when the level is disabled, keeping the per-frame / per-iteration hot loops cheap. - Configurable via environment variables (NCORR_LOG_LEVEL, NCORR_LOG_FILE, NCORR_LOG_CONSOLE) since the library has no CLI; the existing `debug` flag lowers the console threshold to DEBUG. Migrated all ~164 print sites in ncorr.cpp, Image2D.cpp, Array2D.h and ROI2D.h to the appropriate level (errors->ERROR, warnings->WARN, progress->INFO, diagnostics->DEBUG). Documented in README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Apply clang-format 18.1.8 (the version pinned by the lint workflow) to the newly added include/ncorr/log.h and src/log.cpp so the 'lint (clang-format on changed files)' check passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Introduces a small, dependency-free leveled logging facility for CppNCorr and migrates all ad-hoc
std::cout/std::cerr/printfoutput to it. This gives users control over what the engine reports (info / warning / error) and where it goes, with proper verbosity-vs-debug separation.What's new
include/ncorr/log.h+src/log.cpp— a tiny logger (no third-party deps):TRACE / DEBUG / INFO / WARN / ERRORplusOFF.DEBUGdetail while the console stays quiet.NLOG_TRACE/DEBUG/INFO/WARN/ERRORthat short-circuit message construction when the level is disabled — important for the per-frame / per-iteration hot loops inncorr.cpp.NCORR_LOG_LEVEL,NCORR_LOG_FILE,NCORR_LOG_CONSOLE(applied lazily on first use).debugflag lowers the console threshold toDEBUG.ncorr::log::set_level(),set_file(),Logger::instance().Migration
All ~164 print sites migrated and categorized: genuine errors →
ERROR,WARNING-prefixed →WARN, progress/status →INFO, debug-gated dumps andDEBUG-prefixed diagnostics →DEBUG. The per-frame/per-iteration progress prints now route through guarded macros so they cost nothing when the level is off.src/ncorr.cpp(~142 sites),src/Image2D.cpp(15),include/Array2D.h(2),include/ROI2D.h(1).set_debug(debug)wired at theRGDICentry points so the existing flag still controls debug verbosity.Build & verification
src/log.cpp/include/ncorr/log.hintoCMakeLists.txt.libncorr.abuilds clean (only pre-existing template deprecation warnings).libncorr.a: level thresholds, env-var control, and the file sink all behave correctly.README.md.🤖 Generated with Claude Code