Repository navigation
[FEATURE] Add thread-local logging to fix data races (issue #8596) - #8610
timosachsenberg wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughAdds thread-local logging support infrastructure to the LogStream framework by introducing new LogStreamBuf constructors for state copying, stream-list accessors, flushIncomplete() methods, and thread-local LogStream getter functions. Updates macros and tests to route logging through thread-local streams while maintaining backward compatibility with global log streams. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @src/openms/include/OpenMS/CONCEPT/LogStream.h:
- Around line 514-537: The comment block describing the feature flag
OPENMS_THREADLOCAL_LOGGING is incorrect about the default; update the wording so
it reflects that thread-local logging is enabled by default
(OPENMS_THREADLOCAL_LOGGING ON) and that legacy logging is the
opt-in/compatibility mode, e.g. replace "Default is OFF (legacy behavior)" with
a concise statement that the default is ON (thread-local, thread-safe logging)
and legacy macros (OPENMS_LOG_*_LEGACY) are used only when the flag is unset.
🧹 Nitpick comments (4)
src/openms/include/OpenMS/CONCEPT/sources.cmake (1)
19-19: Consider repositioning for alphabetical consistency.The header list appears to be alphabetically sorted, but
ThreadLogContext.his placed betweenMacros.handMacrosTest.h. For consistency with the alphabetical ordering, it should be positioned afterTypes.h(line 26) and beforeUniqueIdGenerator.h(line 27).📝 Suggested position
Move line 19 to between lines 26 and 27 to maintain alphabetical order.
src/openms/source/CONCEPT/sources.cmake (1)
17-17: Consider repositioning for alphabetical consistency.The source list appears to be alphabetically sorted, but
ThreadLogContext.cppis placed betweenPrecisionWrapper.cppandProgressLogger.cpp. For consistency with the alphabetical ordering, it should be positioned afterTypes.cpp(line 21) and beforeUniqueIdGenerator.cpp(line 22).📝 Suggested position
Move line 17 to between lines 21 and 22 to maintain alphabetical order.
src/tests/class_tests/openms/source/ThreadLogContext_test.cpp (1)
266-287: Consider adding test for the exact line number in debug output.The regex test verifies the file/line format pattern, but the test could be more precise by checking the actual line number where
OPENMS_LOG_DEBUG_TLis called (Line 273).💡 Optional: More precise line number verification
- boost::regex rx(R"(ThreadLogContext_test\.cpp\(\d+\))"); + // Line 273 is where OPENMS_LOG_DEBUG_TL is called + boost::regex rx(R"(ThreadLogContext_test\.cpp\(273\))");src/openms/source/CONCEPT/ThreadLogContext.cpp (1)
99-153: Clean public API implementation.The static methods correctly delegate to the thread-local storage via
getThreadLogStreams(). TheisInitialized(),ensureInitialized(),reset(), andflushAll()methods properly handle the optional nature oftls_streams.Per coding guidelines, source files should include ~5% comments. Consider adding brief inline comments explaining the purpose of key sections (e.g., why
reset()callsensureInitialized()whentls_streamsis null).
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
CMakeLists.txtdoc/thread-local-logging-plan.mdsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/include/OpenMS/config.h.insrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/ThreadLogContext_test.cpp
🧰 Additional context used
📓 Path-based instructions (14)
CMakeLists.txt
📄 CodeRabbit inference engine (AGENTS.md)
Use CMake C++ standard C++20 and minimum CMake version 3.21 for OpenMS builds
Files:
CMakeLists.txt
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx,h,hpp,hxx}: Never usestd::endl; use\nfor performance
Use 2-space indentation for C++/headers; no tabs; Unix line endings
Use classes/types/namespaces in PascalCase
Use lowerCamelCase for method names
Use snake_case for variable names
Use trailing underscore for private/protected member variable names
Use UPPER_SNAKE_CASE for enums and macros
Include space after keywords (if,for,while) and around binary operators
Avoid the C++ preprocessor; preferenum classover macro constants
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{h,hpp,hxx}: Never addusing namespaceorusing std::...in header files; allowed in.cppfiles only
Follow the Rule-of-0 or Rule-of-6 for class definitions; no user-defined destructors unless necessary
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/include/**/*.{h,hpp,hxx}: AddOPENMS_DLLAPImacro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Use getter/setter pairs (get/set methods) for protected/private members; no reference getters for primitive types
Use Doxygen documentation with/** */block comments and@tags (not\backslash);@briefis required
Include@param[in],@param[out], or@param[in,out]direction tags for all method parameters in Doxygen documentation
Prefer forward declarations in headers; include only base class headers, non-pointer members, and templates
Always implement and include$Maintainer:marker in file headers, along with$Authors:and copyright notice
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}: PreferOpenMS::Stringfor numeric formatting and parsing instead of standard stream operators
UseSize/SignedSizetypes for STL.size()values instead of raw integers
Use OpenMS primitive types fromOpenMS/CONCEPT/Types.h
Derive custom exceptions fromException::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
UseOpenMS/CONCEPT/Types.hprimitive types instead of standard C++ types for consistency
Use lower_case_with_underscores for method/function parameters and document ranges/units
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{h,hpp,hxx,cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include
$Maintainer:$marker in file preamble of every header and source file
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.h
📄 CodeRabbit inference engine (AGENTS.md)
Use templates with
_impl.honly when needed;.hfiles must not include_impl.h
Files:
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx}: Never usestd::coutorstd::cerrdirectly; use OpenMS logging macros instead
Always use braces for control structures, even for single-line blocks (trivial one-liners may stay single-line)
Braces for control structures must align with opening/closing braces on their own lines
Files:
src/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
src/tests/class_tests/openms/source/**/*_test.cpp
📄 CodeRabbit inference engine (AGENTS.md)
src/tests/class_tests/openms/source/**/*_test.cpp: UseSTART_SECTIONandEND_SECTIONmacros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
UseNEW_TMP_FILEmacro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used withSTART_SECTIONmacro
Files:
src/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
src/openms/source/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include at least ~5% of code as comments in C++ using
//style, plain English describing the next few lines
Files:
src/openms/source/CONCEPT/ThreadLogContext.cpp
src/openms/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
OPENMS_LOG_WARN,OPENMS_LOG_INFO, and other OpenMS logging macros instead ofstd::coutorstd::cerr
Files:
src/openms/source/CONCEPT/ThreadLogContext.cpp
🧠 Learnings (28)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/openms/include/OpenMS/config.h.inCMakeLists.txtsrc/openms/include/OpenMS/CONCEPT/sources.cmakedoc/thread-local-logging-plan.mdsrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Applied to files:
src/openms/include/OpenMS/config.h.inCMakeLists.txtdoc/thread-local-logging-plan.mdsrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
Applied to files:
src/openms/include/OpenMS/config.h.inCMakeLists.txtsrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Add `OPENMS_DLLAPI` macro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Applied to files:
src/openms/include/OpenMS/config.h.insrc/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `NEW_TMP_FILE` macro for each output file in tests to avoid side effects
Applied to files:
src/openms/include/OpenMS/config.h.insrc/tests/class_tests/openms/executables.cmakesrc/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{h,hpp,hxx,cpp,cc,cxx} : Include `$Maintainer:$` marker in file preamble of every header and source file
Applied to files:
src/openms/include/OpenMS/config.h.in
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use OpenMS primitive types from `OpenMS/CONCEPT/Types.h`
Applied to files:
src/openms/include/OpenMS/config.h.insrc/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/source/CONCEPT/sources.cmakesrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/config.h.insrc/openms/include/OpenMS/CONCEPT/sources.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Use Doxygen documentation with `/** */` block comments and `@` tags (not `\` backslash); `brief` is required
Applied to files:
src/openms/include/OpenMS/config.h.in
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Prefer `OpenMS::String` for numeric formatting and parsing instead of standard stream operators
Applied to files:
src/openms/include/OpenMS/config.h.insrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to CMakeLists.txt : Use CMake C++ standard C++20 and minimum CMake version 3.21 for OpenMS builds
Applied to files:
src/openms/include/OpenMS/config.h.inCMakeLists.txt
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add unit tests in `src/tests/class_tests/openms/source/ClassName_test.cpp` and register in `executables.cmake` for all new classes
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/tests/class_tests/openms/executables.cmakeCMakeLists.txtsrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `START_SECTION` and `END_SECTION` macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms_gui/source/**/*_test.cpp : GUI tests must be located in `src/tests/class_tests/openms_gui/source/` and use Qt TestLib framework
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add TOPP tests in `src/tests/topp/CMakeLists.txt` with corresponding test data files
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Wrap template methods with 2+ arguments in parentheses when used with `START_SECTION` macro
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/ThreadLogContext_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Define tool parameters in `registerOptionsAndFlags_()` method and read with `getStringOption_` and related helpers
Applied to files:
CMakeLists.txt
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Set `CMAKE_BUILD_TYPE=Debug` for development builds to keep assertions and pre/post-conditions enabled
Applied to files:
CMakeLists.txt
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use `OpenMS/CONCEPT/Types.h` primitive types instead of standard C++ types for consistency
Applied to files:
src/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.h : Use templates with `_impl.h` only when needed; `.h` files must not include `_impl.h`
Applied to files:
src/openms/include/OpenMS/CONCEPT/sources.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Prefer forward declarations in headers; include only base class headers, non-pointer members, and templates
Applied to files:
src/openms/include/OpenMS/CONCEPT/sources.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Always implement and include `$Maintainer:` marker in file headers, along with `$Authors:` and copyright notice
Applied to files:
src/openms/include/OpenMS/CONCEPT/sources.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Use `ProgressLogger` in TOPP tools for progress reporting
Applied to files:
src/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
🧬 Code graph analysis (3)
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h (2)
src/openms/include/OpenMS/CONCEPT/LogStream.h (3)
OpenMS(22-546)Logger(52-435)OPENMS_DLLAPI(238-261)src/openms/source/CONCEPT/ThreadLogContext.cpp (21)
fatal(43-59)fatal(61-68)fatal(99-102)fatal(99-99)error(104-107)error(104-104)warn(109-112)warn(109-109)info(114-117)info(114-114)debug(119-122)debug(119-119)isInitialized(124-127)isInitialized(124-124)ensureInitialized(129-132)ensureInitialized(129-129)reset(134-144)reset(134-134)flushAll(70-80)flushAll(146-152)flushAll(146-146)
src/tests/class_tests/openms/source/ThreadLogContext_test.cpp (2)
src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h (2)
OpenMS(14-79)Logger(17-20)src/openms/source/CONCEPT/ThreadLogContext.cpp (21)
fatal(43-59)fatal(61-68)fatal(99-102)fatal(99-99)error(104-107)error(104-104)warn(109-112)warn(109-109)info(114-117)info(114-114)debug(119-122)debug(119-119)isInitialized(124-127)isInitialized(124-124)ensureInitialized(129-132)ensureInitialized(129-129)reset(134-144)reset(134-134)flushAll(70-80)flushAll(146-152)flushAll(146-146)
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
src/openms/source/CONCEPT/ThreadLogContext.cpp (12)
fatal(43-59)fatal(61-68)fatal(99-102)fatal(99-99)error(104-107)error(104-104)warn(109-112)warn(109-109)info(114-117)info(114-114)debug(119-122)debug(119-119)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build-lnx
- GitHub Check: build-win
- GitHub Check: build-lnx-arm
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: cppcheck-test
🔇 Additional comments (20)
CMakeLists.txt (1)
63-63: LGTM!The CMake option is well-defined with a clear description referencing the specific issue (#8596). The default value of
ONis appropriate for enabling the data race fix by default while allowing users to opt out if needed.src/tests/class_tests/openms/executables.cmake (2)
12-12: LGTM!The test executable is correctly added to the
concept_executables_list, which is the appropriate category for testing a CONCEPT module class.
649-649: LGTM!Adding
ThreadLogContext_testtoBoost_dependent_testsis consistent withLogStream_testalso being in this list (line 648), and makes sense given the logging infrastructure's dependencies.src/openms/include/OpenMS/config.h.in (1)
159-162: LGTM!The configuration macro is well-documented with clear comments explaining its purpose and behavior. The default value of
1correctly aligns with the CMake option default ofON, and the reference to issue #8596 provides helpful context.src/tests/class_tests/openms/source/ThreadLogContext_test.cpp (5)
1-32: LGTM! Well-structured test file with proper setup.The file includes all required headers, proper copyright/maintainer preamble, and correctly uses the OpenMS test framework with
START_TESTandEND_TEST.
38-72: Good coverage of basic log stream accessors.These tests correctly verify that each
ThreadLogContextaccessor returns aLogStreamwith the expected level. The tests are concise and follow theSTART_SECTION/END_SECTIONpattern.
74-105: Good lifecycle method coverage.The tests for
isInitialized(),ensureInitialized(),reset(), andflushAll()properly verify the initialization state and that these methods don't crash. UsingNOT_TESTABLEforflushAll()is appropriate since it has no observable return value.
146-193: Solid multi-threaded test with proper synchronization.The use of
std::atomicforcompleted_countandhas_own_prefixis correct for thread-safe counting. The test properly verifies thread isolation by checking that each thread's output contains only its own marker.
195-237: Good OpenMP test coverage with conditional compilation.The OpenMP test is properly guarded with
#ifdef _OPENMPand uses atomic counters appropriately. This validates the key use case for thread-local logging.src/tests/class_tests/openms/source/LogStream_test.cpp (5)
375-410: Good dual-path test structure for OPENMS_LOG_FATAL_ERROR.The conditional compilation correctly handles both thread-local and legacy logging modes. The comment about
clearCache()ordering is helpful. The thread-local path properly cleans up by removing the test stream.
412-439: Consistent pattern for OPENMS_LOG_ERROR test.The structure mirrors the FATAL_ERROR test with appropriate stream handling for both modes.
441-468: OPENMS_LOG_WARN test follows the established pattern.Correctly handles both thread-local and legacy modes with proper stream manipulation.
470-498: OPENMS_LOG_INFO test includes cache clearing for legacy mode too.Good addition of
clearCache()for the legacy path (Line 484-485), maintaining consistency in behavior between both modes.
500-534: OPENMS_LOG_DEBUG test properly handles both paths.The debug test correctly includes cache clearing for both thread-local and legacy modes, ensuring consistent test behavior.
src/openms/include/OpenMS/CONCEPT/LogStream.h (2)
437-470: Well-designed thread-local logging macros.The thread-local macros correctly use
ThreadLogContextaccessors without any critical section wrapping, which eliminates the data races. The debug macros properly include file/line information usingpast_last_slash(__FILE__).
471-513: Good documentation of legacy macro limitations.The detailed comments explaining the data race bugs in the legacy macros (static buffer,
incomplete_line_, cache maps) provide valuable context for maintainers.src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h (1)
1-79: Well-structured header with good documentation.The header follows OpenMS conventions with proper
OPENMS_DLLAPIexport, forward declarations to minimize includes, and comprehensive Doxygen documentation including a usage example. The static-only class design is appropriate for providing thread-local accessors.doc/thread-local-logging-plan.md (1)
1-513: Comprehensive design document with good problem analysis.The document provides excellent context on the data race issues (with specific line number references) and rationale for the thread-local approach. Note that the actual implementation differs slightly from the plan (e.g., static methods instead of
getInstance()pattern), which is normal as designs evolve during implementation. Features likeThreadLogConfigManagerand per-thread file routing appear to be planned for future phases.src/openms/source/CONCEPT/ThreadLogContext.cpp (2)
1-15: Good header setup with necessary includes.The includes are minimal and appropriate: the class header, LogStream for the stream types, and Colorizer for color constants.
19-97: Well-implemented thread-local storage pattern.The anonymous namespace correctly encapsulates the implementation details. The use of
thread_local std::unique_ptr<ThreadLogStreamsImpl>ensures each thread gets its own streams with automatic cleanup. ThegetThreadLogStreams()function provides safe lazy initialization.A note on the use of
std::cout/std::cerrat Lines 48-57: this is acceptable as these are the output destinations being configured for the log streams, not direct console output bypassing the logging system.
|
once confirmed correct will remove flag |
Implement thread-local LogStream instances to eliminate race conditions that occur when multiple threads use OPENMS_LOG_* macros simultaneously. The race conditions affected sync() method operations on shared buffers, incomplete_line_ state, and log caches. Key changes: - Add ThreadLogContext class providing per-thread LogStream instances - Add _TL (thread-local) and _LEGACY macro variants in LogStream.h - Add OPENMS_THREADLOCAL_LOGGING CMake option (ON by default) - Update LogStream_test to work with both modes - Add comprehensive ThreadLogContext_test with multi-threaded tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
5de3013 to
7f60b9a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
CMakeLists.txtsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/include/OpenMS/CONCEPT/ThreadLogContext.hsrc/openms/include/OpenMS/CONCEPT/sources.cmakesrc/openms/include/OpenMS/config.h.insrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/ThreadLogContext_test.cpp
🚧 Files skipped from review as they are similar to previous changes (6)
- src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
- src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
- src/tests/class_tests/openms/source/LogStream_test.cpp
- src/openms/include/OpenMS/CONCEPT/sources.cmake
- src/openms/include/OpenMS/config.h.in
- CMakeLists.txt
🧰 Additional context used
📓 Path-based instructions (11)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx}: Never usestd::coutorstd::cerrdirectly; use OpenMS logging macros instead
Always use braces for control structures, even for single-line blocks (trivial one-liners may stay single-line)
Braces for control structures must align with opening/closing braces on their own lines
Files:
src/openms/source/CONCEPT/ThreadLogContext.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx,h,hpp,hxx}: Never usestd::endl; use\nfor performance
Use 2-space indentation for C++/headers; no tabs; Unix line endings
Use classes/types/namespaces in PascalCase
Use lowerCamelCase for method names
Use snake_case for variable names
Use trailing underscore for private/protected member variable names
Use UPPER_SNAKE_CASE for enums and macros
Include space after keywords (if,for,while) and around binary operators
Avoid the C++ preprocessor; preferenum classover macro constants
Files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}: PreferOpenMS::Stringfor numeric formatting and parsing instead of standard stream operators
UseSize/SignedSizetypes for STL.size()values instead of raw integers
Use OpenMS primitive types fromOpenMS/CONCEPT/Types.h
Derive custom exceptions fromException::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
UseOpenMS/CONCEPT/Types.hprimitive types instead of standard C++ types for consistency
Use lower_case_with_underscores for method/function parameters and document ranges/units
Files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/source/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include at least ~5% of code as comments in C++ using
//style, plain English describing the next few lines
Files:
src/openms/source/CONCEPT/ThreadLogContext.cpp
src/openms/**/*.{h,hpp,hxx,cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include
$Maintainer:$marker in file preamble of every header and source file
Files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
OPENMS_LOG_WARN,OPENMS_LOG_INFO, and other OpenMS logging macros instead ofstd::coutorstd::cerr
Files:
src/openms/source/CONCEPT/ThreadLogContext.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{h,hpp,hxx}: Never addusing namespaceorusing std::...in header files; allowed in.cppfiles only
Follow the Rule-of-0 or Rule-of-6 for class definitions; no user-defined destructors unless necessary
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/include/**/*.{h,hpp,hxx}: AddOPENMS_DLLAPImacro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Use getter/setter pairs (get/set methods) for protected/private members; no reference getters for primitive types
Use Doxygen documentation with/** */block comments and@tags (not\backslash);@briefis required
Include@param[in],@param[out], or@param[in,out]direction tags for all method parameters in Doxygen documentation
Prefer forward declarations in headers; include only base class headers, non-pointer members, and templates
Always implement and include$Maintainer:marker in file headers, along with$Authors:and copyright notice
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.h
📄 CodeRabbit inference engine (AGENTS.md)
Use templates with
_impl.honly when needed;.hfiles must not include_impl.h
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `NEW_TMP_FILE` macro for each output file in tests to avoid side effects
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Applied to files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
Applied to files:
src/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use OpenMS primitive types from `OpenMS/CONCEPT/Types.h`
Applied to files:
src/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use `OpenMS/CONCEPT/Types.h` primitive types instead of standard C++ types for consistency
Applied to files:
src/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `START_SECTION` and `END_SECTION` macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Applied to files:
src/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/source/CONCEPT/sources.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `NEW_TMP_FILE` macro for each output file in tests to avoid side effects
Applied to files:
src/openms/source/CONCEPT/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Use `ProgressLogger` in TOPP tools for progress reporting
Applied to files:
src/openms/source/CONCEPT/sources.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add unit tests in `src/tests/class_tests/openms/source/ClassName_test.cpp` and register in `executables.cmake` for all new classes
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/executables.cmakesrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms_gui/source/**/*_test.cpp : GUI tests must be located in `src/tests/class_tests/openms_gui/source/` and use Qt TestLib framework
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add TOPP tests in `src/tests/topp/CMakeLists.txt` with corresponding test data files
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Wrap template methods with 2+ arguments in parentheses when used with `START_SECTION` macro
Applied to files:
src/tests/class_tests/openms/executables.cmake
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Prefer `OpenMS::String` for numeric formatting and parsing instead of standard stream operators
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Add `OPENMS_DLLAPI` macro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-win
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos-arm
- GitHub Check: build-lnx
- GitHub Check: cppcheck-test
🔇 Additional comments (9)
src/tests/class_tests/openms/executables.cmake (1)
12-12: LGTM! Test registration is correct.The ThreadLogContext_test is properly registered in both the concept_executables_list and Boost_dependent_tests, following the established pattern and placed logically near related logging tests.
Also applies to: 649-649
src/openms/source/CONCEPT/sources.cmake (1)
17-17: LGTM! Source file registration is correct.ThreadLogContext.cpp is properly added to the CONCEPT sources list with correct alphabetical ordering.
src/openms/include/OpenMS/CONCEPT/LogStream.h (2)
12-12: LGTM! Proper header inclusion.Including ThreadLogContext.h is necessary for the thread-local logging macros and is placed appropriately with other CONCEPT headers.
437-469: LGTM! Thread-local macros are correctly implemented.The thread-local macros properly delegate to ThreadLogContext static methods. The absence of OPENMS_THREAD_CRITICAL is correct here since each thread operates on isolated state, eliminating the data races present in the legacy macros.
src/openms/source/CONCEPT/ThreadLogContext.cpp (5)
1-11: LGTM! File header and includes are correct.The file has proper copyright notice, maintainer, and authors information. The included headers (ThreadLogContext.h, LogStream.h, Colorizer.h, iostream, memory) are appropriate for the implementation.
19-81: LGTM! ThreadLogStreamsImpl implementation is sound.The internal implementation struct correctly manages per-thread LogStream instances with proper RAII semantics:
- Constructor initializes all streams
- Destructor flushes before destruction
- Each thread gets isolated buffers, caches, and state (eliminating the data races described in issue #8596)
The initialization creates LogStreamBuf instances with appropriate log levels and output streams matching the global configuration.
86-95: LGTM! Thread-local storage is correctly implemented.The use of
thread_localfortls_streamsensures each thread gets its own instance, and the lazy initialization ingetThreadLogStreams()is appropriate for on-demand construction.
99-152: LGTM! Public API implementation is correct.The accessor methods (fatal, error, warn, info, debug) properly return references to the thread-local streams via
getThreadLogStreams(). The lifecycle methods (isInitialized, ensureInitialized, reset, flushAll) provide appropriate control over the thread-local logging state.Minor observation: The
initializedflag check inisInitialized()is technically redundant since it's always true after construction, but it doesn't harm functionality and may provide future extensibility.
47-57: Remove this comment — Colorizer instances are properly declared.The symbols
red,yellow, andmagentaare properly declared withextern OPENMS_DLLAPIinsrc/openms/include/OpenMS/CONCEPT/Colorizer.h(lines 202, 204, 206) and defined insrc/openms/source/CONCEPT/Colorizer.cpp(lines 194, 196, 198). No linker errors will occur.Likely an incorrect or invalid review comment.
| /// Macro to be used if non-fatal error are reported (processing continues) | ||
| #define OPENMS_LOG_ERROR \ | ||
| /// Legacy macro for non-fatal errors - has data race bugs | ||
| #define OPENMS_LOG_ERROR_LEGACY \ |
There was a problem hiding this comment.
mhh... a simply function which avoids exposing a thread_local variable to the ABI would have done the trick, no?!
Logger::LogStream& getOpenMSLogFatal() { thread_local Logger::LogStream tls_log; return tls_log; }
??
The solution from Claude is more flexible, but also horribly overengineered?!
There was a problem hiding this comment.
I think this is currently because it wanted to pertain API / backwards compatibility with some other classees. If this is going in the right direction I will completely switch to this approach and simplify.
There was a problem hiding this comment.
Addressing cbielow's Concern
The reviewer suggested:
Logger::LogStream& getOpenMSLogFatal() {
thread_local Logger::LogStream tls_log;
return tls_log;
}
Why the current design is more complex:
- Thread-local streams need to inherit configuration from somewhere (the globals)
- flushAll() is needed before LogConfigHandler reconfigures log levels
- reset() is needed for test cleanup
Simplest viable approach (if we keep configuration inheritance):
// Could replace ThreadLogContext class with 5 simple functions:
Logger::LogStream& getThreadLocalFatal() {
thread_local Logger::LogStream tls(OpenMS_Log_fatal); // Copy from global
return tls;
}
// ... repeat for error, warn, info, debug
But this loses:
- Coordinated flushAll() before reconfiguration
- reset() for test cleanup
- isInitialized() checks
Recommendation
Two options to present to cbielow:
- Keep ThreadLogContext but remove all legacy code paths (~135 lines deleted, class stays)
- Replace with simple functions but then need to:
- Remove flushAll() call from LogConfigHandler (accept potential partial-line issues)
- Handle test cleanup differently (or accept state leakage between tests)
Want me to implement option 1 (remove legacy code, keep ThreadLogContext), or prepare a prototype of option 2 (simple functions)?
Thread-local logging was not picking up stream configuration changes made via LogConfigHandler or direct stream manipulation. This caused test failures in Param_test and LogConfigHandler_test. Changes: - Add LogStreamBuf constructor to copy stream_list_ from source buffer - Thread-local streams now copy initial config from global streams - Add LogStream::flushIncomplete() to flush unterminated lines - LogConfigHandler::setLogLevel() now flushes thread-local buffers - Update tests to call ThreadLogContext::reset() after config changes - Simplify LogStream_test OpenMP test to avoid stream lifetime issues Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @src/openms/include/OpenMS/CONCEPT/LogStream.h:
- Around line 435-441: Add a Doxygen @brief tag to the public method
documentation for LogStream::flushIncomplete(); update the comment block
immediately above the void flushIncomplete() declaration to start with a concise
@brief line describing the purpose (e.g., flushing any incomplete line to all
streams) and keep the existing longer explanation below it so the public API has
the required @brief tag.
🧹 Nitpick comments (1)
src/openms/include/OpenMS/CONCEPT/LogStream.h (1)
200-202: Consider expanding the documentation for the accessors.The documentation is minimal but acceptable for protected API. However, since these accessors are part of the thread-local logging integration, a brief note about their purpose would improve clarity.
📝 Suggested enhancement
- /// Returns the stream list (owned or shared) + /// Returns the stream list for this buffer (used by thread-local logging to access/copy configuration) std::list<StreamStruct>& getStreamList_(); const std::list<StreamStruct>& getStreamList_() const;
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/LogStream.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/Param_test.cpp
🧰 Additional context used
📓 Path-based instructions (13)
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx}: Never usestd::coutorstd::cerrdirectly; use OpenMS logging macros instead
Always use braces for control structures, even for single-line blocks (trivial one-liners may stay single-line)
Braces for control structures must align with opening/closing braces on their own lines
Files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/source/CONCEPT/LogStream.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx,h,hpp,hxx}: Never usestd::endl; use\nfor performance
Use 2-space indentation for C++/headers; no tabs; Unix line endings
Use classes/types/namespaces in PascalCase
Use lowerCamelCase for method names
Use snake_case for variable names
Use trailing underscore for private/protected member variable names
Use UPPER_SNAKE_CASE for enums and macros
Include space after keywords (if,for,while) and around binary operators
Avoid the C++ preprocessor; preferenum classover macro constants
Files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
src/tests/class_tests/openms/source/**/*_test.cpp
📄 CodeRabbit inference engine (AGENTS.md)
src/tests/class_tests/openms/source/**/*_test.cpp: UseSTART_SECTIONandEND_SECTIONmacros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
UseNEW_TMP_FILEmacro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used withSTART_SECTIONmacro
Files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}: PreferOpenMS::Stringfor numeric formatting and parsing instead of standard stream operators
UseSize/SignedSizetypes for STL.size()values instead of raw integers
Use OpenMS primitive types fromOpenMS/CONCEPT/Types.h
Derive custom exceptions fromException::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
UseOpenMS/CONCEPT/Types.hprimitive types instead of standard C++ types for consistency
Use lower_case_with_underscores for method/function parameters and document ranges/units
Files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
src/openms/source/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include at least ~5% of code as comments in C++ using
//style, plain English describing the next few lines
Files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/LogStream.cpp
src/openms/**/*.{h,hpp,hxx,cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include
$Maintainer:$marker in file preamble of every header and source file
Files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
src/openms/**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
OPENMS_LOG_WARN,OPENMS_LOG_INFO, and other OpenMS logging macros instead ofstd::coutorstd::cerr
Files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/openms/source/CONCEPT/LogStream.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{h,hpp,hxx}: Never addusing namespaceorusing std::...in header files; allowed in.cppfiles only
Follow the Rule-of-0 or Rule-of-6 for class definitions; no user-defined destructors unless necessary
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/include/**/*.{h,hpp,hxx}: AddOPENMS_DLLAPImacro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Use getter/setter pairs (get/set methods) for protected/private members; no reference getters for primitive types
Use Doxygen documentation with/** */block comments and@tags (not\backslash);@briefis required
Include@param[in],@param[out], or@param[in,out]direction tags for all method parameters in Doxygen documentation
Prefer forward declarations in headers; include only base class headers, non-pointer members, and templates
Always implement and include$Maintainer:marker in file headers, along with$Authors:and copyright notice
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.h
📄 CodeRabbit inference engine (AGENTS.md)
Use templates with
_impl.honly when needed;.hfiles must not include_impl.h
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
🧠 Learnings (28)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `START_SECTION` and `END_SECTION` macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `NEW_TMP_FILE` macro for each output file in tests to avoid side effects
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Wrap template methods with 2+ arguments in parentheses when used with `START_SECTION` macro
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms_gui/source/**/*_test.cpp : GUI tests must be located in `src/tests/class_tests/openms_gui/source/` and use Qt TestLib framework
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add unit tests in `src/tests/class_tests/openms/source/ClassName_test.cpp` and register in `executables.cmake` for all new classes
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/openms/source/CONCEPT/ThreadLogContext.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Prefer `OpenMS::String` for numeric formatting and parsing instead of standard stream operators
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use OpenMS primitive types from `OpenMS/CONCEPT/Types.h`
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Derive custom exceptions from `Exception::Base`; throw with file/line/`OPENMS_PRETTY_FUNCTION`; catch by reference
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Use `ProgressLogger` in TOPP tools for progress reporting
Applied to files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use `OpenMS/CONCEPT/Types.h` primitive types instead of standard C++ types for consistency
Applied to files:
src/openms/source/CONCEPT/LogConfigHandler.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-10-15T07:49:09.293Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h:11-14
Timestamp: 2025-10-15T07:49:09.293Z
Learning: In OpenMS, DefaultParamHandler.h is located under OpenMS/DATASTRUCTURES/, not OpenMS/CONCEPT/. The correct include is: `#include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>`
Applied to files:
src/tests/class_tests/openms/source/Param_test.cpp
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Register TOPP tools in `src/openms/source/APPLICATIONS/ToolHandler.cpp` to generate Doxygen help output
Applied to files:
src/tests/class_tests/openms/source/Param_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Define tool parameters in `registerOptionsAndFlags_()` method and read with `getStringOption_` and related helpers
Applied to files:
src/tests/class_tests/openms/source/Param_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/tests/class_tests/openms/source/Param_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2025-09-16T10:59:20.544Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8208
File: src/openms/source/FORMAT/MzParquetFile.cpp:127-146
Timestamp: 2025-09-16T10:59:20.544Z
Learning: Throwing exceptions from within OpenMP critical sections (#pragma omp critical) can cause undefined behavior and deadlocks because the critical section may not be properly released during exception unwinding. Always avoid throwing exceptions from within OpenMP synchronization constructs.
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Add `OPENMS_DLLAPI` macro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/source/**/*.{cpp,cc,cxx} : Include at least ~5% of code as comments in C++ using `//` style, plain English describing the next few lines
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Use Doxygen documentation with `/** */` block comments and `@` tags (not `\` backslash); `brief` is required
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
🧬 Code graph analysis (6)
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp (2)
src/openms/source/CONCEPT/ThreadLogContext.cpp (2)
reset(144-154)reset(144-144)src/openms/source/CONCEPT/LogConfigHandler.cpp (2)
getInstance(435-442)getInstance(435-435)
src/openms/source/CONCEPT/LogConfigHandler.cpp (1)
src/openms/source/CONCEPT/ThreadLogContext.cpp (3)
flushAll(80-90)flushAll(156-162)flushAll(156-156)
src/tests/class_tests/openms/source/Param_test.cpp (2)
src/openms/source/CONCEPT/ThreadLogContext.cpp (2)
warn(119-122)warn(119-119)src/openms/source/CONCEPT/LogConfigHandler.cpp (2)
os(421-431)os(421-421)
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
src/openms/source/CONCEPT/ThreadLogContext.cpp (12)
fatal(51-67)fatal(69-78)fatal(109-112)fatal(109-109)error(114-117)error(114-114)warn(119-122)warn(119-119)info(124-127)info(124-124)debug(129-132)debug(129-129)
src/openms/include/OpenMS/CONCEPT/LogStream.h (1)
src/openms/source/CONCEPT/LogStream.cpp (9)
LogStreamBuf(42-49)LogStreamBuf(51-63)LogStreamBuf(75-88)getStreamList_(65-68)getStreamList_(65-65)getStreamList_(70-73)getStreamList_(70-70)flushIncomplete(585-597)flushIncomplete(585-585)
src/openms/source/CONCEPT/LogStream.cpp (1)
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
LogStreamBuf(103-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-lnx-arm
- GitHub Check: build-macos-arm
- GitHub Check: build-lnx
- GitHub Check: build-win
- GitHub Check: cppcheck-test
🔇 Additional comments (21)
src/tests/class_tests/openms/source/Param_test.cpp (2)
16-16: LGTM! Include necessary for thread-local logging support.The include is correctly positioned and required for the conditional thread-local logging configuration below.
631-639: LGTM! Correctly adapts test for thread-local logging.The conditional compilation properly handles both modes:
- Thread-local mode configures
ThreadLogContext::warn()- Legacy mode configures global
OpenMS_Log_warnThe file-scope configuration is intentional (per comment at line 1627) to maintain state across multiple test sections. The captured output is appropriately cleared between test sections (e.g., lines 1652, 1661).
src/openms/source/CONCEPT/LogConfigHandler.cpp (2)
13-13: LGTM!The include is correctly placed and necessary for the thread-local logging integration.
228-232: LGTM!The pre-flush ensures incomplete log lines are distributed to streams before reconfiguration. Correct placement and clear rationale.
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp (2)
14-14: LGTM!The include and ThreadLogContext::reset() calls correctly ensure thread-local streams inherit the new configuration after changes.
Also applies to: 71-88
173-193: LGTM!Consistent application of ThreadLogContext::reset() after configuration changes ensures thread-local streams stay synchronized with global configuration.
Also applies to: 222-224, 254-276
src/tests/class_tests/openms/source/LogStream_test.cpp (3)
59-87: LGTM!The simplified OpenMP test correctly avoids stream lifetime issues by using thread-local macros (_TL) when OPENMS_THREADLOCAL_LOGGING is enabled. The comment clearly explains the rationale.
378-537: LGTM!The dual-path test structure correctly validates both thread-local and legacy logging modes. The clearCache() calls before inserting test streams prevent cached messages from being output to the wrong stream, which is critical for test accuracy.
21-21: LGTM!Include is necessary for thread-local stream access in conditional test paths.
src/openms/source/CONCEPT/ThreadLogContext.cpp (5)
1-24: LGTM!Standard file header with appropriate includes and external declarations.
28-91: LGTM!The ThreadLogStreamsImpl properly manages per-thread log streams with RAII semantics. Flush-on-destruction ensures incomplete log lines are not lost when threads exit.
93-105: LGTM!Correct use of thread_local storage with lazy initialization. Each thread gets its own log stream instances that are automatically cleaned up on thread exit.
109-132: LGTM!Consistent accessor pattern for all log levels. Returns references rather than pointers, which is safer and more idiomatic.
134-162: LGTM!Lifecycle management methods correctly handle all cases including uninitialized thread-local storage. The reset() method properly flushes before reinitializing to prevent data loss.
src/openms/source/CONCEPT/LogStream.cpp (3)
51-63: LGTM!The constructor correctly enables thread-local buffers with shared stream configuration. Each thread gets its own buffer (pbuf_) but shares the output streams (stream_list_), which is the intended behavior for thread-safe logging.
65-73: LGTM!Standard const/non-const accessor pair for stream_list_. Necessary for thread-local logging integration to copy stream configurations.
585-597: LGTM!The flushIncomplete() method correctly flushes buffered incomplete lines without removing streams. This is essential for ensuring log data is not lost during configuration changes in thread-local logging mode.
src/openms/include/OpenMS/CONCEPT/LogStream.h (4)
12-12: LGTM! Thread-local logging header integration.The include of
ThreadLogContext.his necessary for the thread-local logging macros defined later in this header. The placement is appropriate.
461-543: Excellent documentation of the thread-safety improvements.The extensive comments clearly explain:
- The data race issues in the legacy approach (static buffers, incomplete_line_, caches)
- The thread-local solution and its benefits
- The feature flag mechanism for switching between modes
This level of documentation is appropriate given the critical nature of the data race fixes (issue #8596).
105-115: Add parameter direction tags to Doxygen documentation.The Doxygen documentation is clear, but it's missing the required
@param[in]direction tags for the parameters.📝 Proposed fix
/** Create a LogStreamBuf that copies the stream_list_ configuration from another LogStreamBuf. This constructor is used for thread-local logging where each thread has its own buffer and stream configuration (for thread safety), but starts with the same initial configuration as the global LogStream instances. - @param[in] source_buf The LogStreamBuf whose stream_list_ should be copied - @param[in] col If messages should be colored, provide a colorizer here + @param[in] source_buf The LogStreamBuf whose stream_list_ should be copied + @param[in] col If messages should be colored, provide a colorizer here */ LogStreamBuf(LogStreamBuf* source_buf, Colorizer* col = nullptr);As per coding guidelines, include
@param[in],@param[out], or@param[in,out]direction tags for all method parameters in Doxygen documentation.⛔ Skipped due to learnings
Learnt from: CR Repo: OpenMS/OpenMS PR: 0 File: AGENTS.md:0-0 Timestamp: 2026-01-07T06:33:27.218Z Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Include `param[in]`, `param[out]`, or `param[in,out]` direction tags for all method parameters in Doxygen documentationLearnt from: CR Repo: OpenMS/OpenMS PR: 0 File: AGENTS.md:0-0 Timestamp: 2026-01-07T06:33:27.218Z Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Use Doxygen documentation with `/** */` block comments and `@` tags (not `\` backslash); `brief` is required
12-12: ThreadLogContext integration and CMake configuration are correctly implemented.All verification points pass:
- ThreadLogContext class contains all required static accessor methods (fatal, error, warn, info, debug) with comprehensive Doxygen documentation and proper OPENMS_DLLAPI decoration
- CMake option
OPENMS_THREADLOCAL_LOGGINGis correctly defined in CMakeLists.txt with default value ON- Global log stream externs (OpenMS_Log_fatal, OpenMS_Log_error, OpenMS_Log_warn, OpenMS_Log_info, OpenMS_Log_debug) are declared in LogStream.h and properly defined in LogStream.cpp
Response to Over-Engineering Concern@cbielow You raised a good point about whether a simpler approach would suffice: Logger::LogStream& getOpenMSLogFatal() {
thread_local Logger::LogStream tls_log;
return tls_log;
}The 1.
|
| Function | If Lost | Severity |
|---|---|---|
flushAll() |
Rare garbled output during reconfiguration | Low |
reset() |
Test pollution, flaky tests | High |
isInitialized()/ensureInitialized() |
Config timing edge cases | Low |
The class could be replaced with 5 simple functions if we accept losing reset() (and accept test isolation issues) or implement an alternative reset mechanism.
Options:
- Keep
ThreadLogContextas-is (current approach) - Simplify to functions + add a
thread_local boolreset flag for tests - Simplify to functions and accept test isolation challenges
Let me know your preference and I can refactor accordingly.
|
these are good points, let me address them: This should not be a supported use-case. Log configuration should be done once in the beginning globally, and then copied by all threads. What prevents you from resetting the thread_local streams in the tests? |
|
the loghandler is complicated enough as it is. The new structure adds too much complexity and increases maintenance burden (since wrapping your head around it and reasoning about it is very hard). So keep it as simple as possible and document restrictions and do's and don'ts. |
|
I am almost inclined to go back to a single shared global state with mutexes, although this means a potentially considerable performance hit (we should actually measure this for tools that are heavy in logging). |
|
Thanks for testing OpenMP. starting to understand why some logging libraries took years to stabilize :) |
Address reviewer feedback (cbielow) to simplify thread-local logging: - Remove ThreadLogContext class entirely (~250 lines) - Add 5 simple thread-local accessor functions: - getThreadLocalLogFatal() - getThreadLocalLogError() - getThreadLocalLogWarn() - getThreadLocalLogInfo() - getThreadLocalLogDebug() - Remove OPENMS_THREADLOCAL_LOGGING CMake feature flag - Remove legacy logging macros (always use thread-local now) - Document restrictions: configure logging once at startup, before spawning threads The thread-local streams copy stream_list_ from globals on first access, so configuration propagates to new threads automatically. Tests updated: - LogConfigHandler_test uses global streams directly (tests what LogConfigHandler actually configures) - LogStream_test uses thread-local accessors - Removed ThreadLogContext_test Net change: -660 lines (removed 789, added 129) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @src/openms/include/OpenMS/CONCEPT/LogStream.h:
- Around line 475-487: The five thread-local log accessor functions
(getThreadLocalLogFatal, getThreadLocalLogError, getThreadLocalLogWarn,
getThreadLocalLogInfo, getThreadLocalLogDebug) lack proper Doxygen block
comments; add a /** @brief ... */ Doxygen comment block above each OPENMS_DLLAPI
declaration describing the purpose (e.g., returns the thread-local LogStream for
fatal/error/warn/info/debug messages) and include any relevant tags such as
@return Logger::LogStream& to match the project’s public API documentation
style.
🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
371-383: Consider RAII guards for test stream management.The test pattern of
clearCache() → removeAllStreams() → insert() → [test] → remove()is correct but fragile. If a test throws an exception before callingremove(), the stream remains attached and could affect subsequent tests.Consider wrapping stream insertion/removal in an RAII guard class:
📝 Suggested RAII wrapper
// Helper class for tests class LogStreamGuard { Logger::LogStream& log; std::ostream& stream; public: LogStreamGuard(Logger::LogStream& l, std::ostream& s) : log(l), stream(s) { log.rdbuf()->clearCache(); log.removeAllStreams(); log.insert(stream); } ~LogStreamGuard() { log.remove(stream); } }; // Usage: { ostringstream stream_by_logger; LogStreamGuard guard(getThreadLocalLogFatal(), stream_by_logger); OPENMS_LOG_FATAL_ERROR << "1\n"; OPENMS_LOG_FATAL_ERROR << "2" << endl; }Also applies to: 399-413, 421-435, 443-457, 465-477
src/openms/include/OpenMS/CONCEPT/LogStream.h (1)
468-471: Clarify consequences of violating documented restrictions.The restrictions are documented but don't explain what happens if they're violated. This could lead to subtle bugs if developers don't understand the implications.
📝 Suggested clarification
// RESTRICTIONS (document these clearly): // - Log configuration (via LogConfigHandler) should be done ONCE at program start, // BEFORE spawning threads. Thread-local streams copy config from globals on first access. +// Violating this may result in inconsistent configuration across threads. // - OpenMP thread pools reuse threads, so thread_local state persists across parallel regions. +// This means test cleanup must be thorough to avoid cross-contamination. // - Do not reconfigure logging while threads are actively logging. +// This can cause lost messages or partially configured streams.This helps developers understand the severity and impact of not following the restrictions.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/openms/include/OpenMS/CONCEPT/LogStream.hsrc/openms/source/CONCEPT/LogStream.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/Param_test.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openms/source/CONCEPT/LogStream.cpp
🧰 Additional context used
📓 Path-based instructions (11)
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
**/*.{cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx}: Never usestd::coutorstd::cerrdirectly; use OpenMS logging macros instead
Always use braces for control structures, even for single-line blocks (trivial one-liners may stay single-line)
Braces for control structures must align with opening/closing braces on their own lines
Files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{cpp,cc,cxx,h,hpp,hxx}: Never usestd::endl; use\nfor performance
Use 2-space indentation for C++/headers; no tabs; Unix line endings
Use classes/types/namespaces in PascalCase
Use lowerCamelCase for method names
Use snake_case for variable names
Use trailing underscore for private/protected member variable names
Use UPPER_SNAKE_CASE for enums and macros
Include space after keywords (if,for,while) and around binary operators
Avoid the C++ preprocessor; preferenum classover macro constants
Files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
src/tests/class_tests/openms/source/**/*_test.cpp
📄 CodeRabbit inference engine (AGENTS.md)
src/tests/class_tests/openms/source/**/*_test.cpp: UseSTART_SECTIONandEND_SECTIONmacros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
UseNEW_TMP_FILEmacro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used withSTART_SECTIONmacro
Files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{h,hpp,hxx}: Never addusing namespaceorusing std::...in header files; allowed in.cppfiles only
Follow the Rule-of-0 or Rule-of-6 for class definitions; no user-defined destructors unless necessary
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/include/**/*.{h,hpp,hxx}: AddOPENMS_DLLAPImacro on all non-template exported classes, structs, functions, and variables; include in friend operator declarations
Use getter/setter pairs (get/set methods) for protected/private members; no reference getters for primitive types
Use Doxygen documentation with/** */block comments and@tags (not\backslash);@briefis required
Include@param[in],@param[out], or@param[in,out]direction tags for all method parameters in Doxygen documentation
Prefer forward declarations in headers; include only base class headers, non-pointer members, and templates
Always implement and include$Maintainer:marker in file headers, along with$Authors:and copyright notice
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx}: PreferOpenMS::Stringfor numeric formatting and parsing instead of standard stream operators
UseSize/SignedSizetypes for STL.size()values instead of raw integers
Use OpenMS primitive types fromOpenMS/CONCEPT/Types.h
Derive custom exceptions fromException::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
UseOpenMS/CONCEPT/Types.hprimitive types instead of standard C++ types for consistency
Use lower_case_with_underscores for method/function parameters and document ranges/units
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/**/*.{h,hpp,hxx,cpp,cc,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Include
$Maintainer:$marker in file preamble of every header and source file
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.h
📄 CodeRabbit inference engine (AGENTS.md)
Use templates with
_impl.honly when needed;.hfiles must not include_impl.h
Files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx} : Use `OPENMS_LOG_WARN`, `OPENMS_LOG_INFO`, and other OpenMS logging macros instead of `std::cout` or `std::cerr`
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `START_SECTION` and `END_SECTION` macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Use `NEW_TMP_FILE` macro for each output file in tests to avoid side effects
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms/source/**/*_test.cpp : Wrap template methods with 2+ arguments in parentheses when used with `START_SECTION` macro
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/tests/class_tests/openms_gui/source/**/*_test.cpp : GUI tests must be located in `src/tests/class_tests/openms_gui/source/` and use Qt TestLib framework
Applied to files:
src/tests/class_tests/openms/source/Param_test.cppsrc/tests/class_tests/openms/source/LogStream_test.cppsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use lower_case_with_underscores for method/function parameters and document ranges/units
Applied to files:
src/tests/class_tests/openms/source/Param_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/topp/**/*.cpp : Use `ProgressLogger` in TOPP tools for progress reporting
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2025-09-16T10:59:20.544Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8208
File: src/openms/source/FORMAT/MzParquetFile.cpp:127-146
Timestamp: 2025-09-16T10:59:20.544Z
Learning: Throwing exceptions from within OpenMP critical sections (#pragma omp critical) can cause undefined behavior and deadlocks because the critical section may not be properly released during exception unwinding. Always avoid throwing exceptions from within OpenMP synchronization constructs.
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cpp
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/**/*.{cpp,cc,cxx,h,hpp,hxx} : Prefer `OpenMS::String` for numeric formatting and parsing instead of standard stream operators
Applied to files:
src/tests/class_tests/openms/source/LogStream_test.cppsrc/openms/include/OpenMS/CONCEPT/LogStream.hsrc/tests/class_tests/openms/source/LogConfigHandler_test.cpp
📚 Learning: 2025-10-21T13:02:16.431Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8318
File: src/openms/include/OpenMS/ML/CLUSTERING/HashGrid.h:466-480
Timestamp: 2025-10-21T13:02:16.431Z
Learning: In OpenMS, when making internal methods public (e.g., in HashGrid.h), remove XXX/TODO comments about implementation details rather than documenting them in the public API documentation.
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Use Doxygen documentation with `/** */` block comments and `@` tags (not `\` backslash); `brief` is required
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.218Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.218Z
Learning: Applies to src/openms/source/**/*.{cpp,cc,cxx} : Include at least ~5% of code as comments in C++ using `//` style, plain English describing the next few lines
Applied to files:
src/openms/include/OpenMS/CONCEPT/LogStream.h
📚 Learning: 2026-01-07T06:33:27.217Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T06:33:27.217Z
Learning: Add unit tests in `src/tests/class_tests/openms/source/ClassName_test.cpp` and register in `executables.cmake` for all new classes
Applied to files:
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
🧬 Code graph analysis (3)
src/tests/class_tests/openms/source/Param_test.cpp (1)
src/openms/source/CONCEPT/LogStream.cpp (2)
getThreadLocalLogWarn(630-634)getThreadLocalLogWarn(630-630)
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
src/openms/source/CONCEPT/LogStream.cpp (10)
getThreadLocalLogFatal(618-622)getThreadLocalLogFatal(618-618)getThreadLocalLogError(624-628)getThreadLocalLogError(624-624)getThreadLocalLogWarn(630-634)getThreadLocalLogWarn(630-630)getThreadLocalLogInfo(636-640)getThreadLocalLogInfo(636-636)getThreadLocalLogDebug(642-646)getThreadLocalLogDebug(642-642)
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp (1)
src/openms/source/CONCEPT/LogConfigHandler.cpp (2)
getInstance(428-435)getInstance(428-428)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-lnx
- GitHub Check: build-macos-arm
- GitHub Check: build-win
- GitHub Check: build-lnx-arm
- GitHub Check: build-and-test (ubuntu-24.04, clang++, 17)
- GitHub Check: build-and-test (macos-14, xcode, 15.4)
- GitHub Check: build-and-test (ubuntu-24.04, g++, 13)
- GitHub Check: build-and-test (windows-2025, cl.exe, 14.44)
- GitHub Check: build-and-test (ubuntu-24.04-arm, g++, 13)
- GitHub Check: cppcheck-test
🔇 Additional comments (6)
src/tests/class_tests/openms/source/Param_test.cpp (1)
1628-1633: LGTM! Clean adaptation to thread-local logging.The test correctly switches from manipulating the global
OpenMS_Log_warnstream to using the thread-local accessorgetThreadLocalLogWarn(). The added comment clarifies the intent, and this approach correctly captures warnings from the current thread's log stream.src/tests/class_tests/openms/source/LogConfigHandler_test.cpp (1)
59-60: LGTM! Correct distinction between global and thread-local streams.The tests appropriately use global log stream instances (
OpenMS_Log_info,OpenMS_Log_warn,OpenMS_Log_error) instead of the thread-local macros (OPENMS_LOG_*). This is correct becauseLogConfigHandlerconfigures global log streams, and the tests need to verify that global configuration works as expected. The added comments effectively clarify this distinction.Also applies to: 73-87, 122-131, 158-181, 199-214, 228-255
src/tests/class_tests/openms/source/LogStream_test.cpp (1)
58-61: Good documentation of thread-local logging limitations with OpenMP.The comment correctly explains why custom streams aren't attached in the OpenMP test: thread-local streams could outlive the custom stream they reference. This is a reasonable constraint given thread_local lifetime semantics with thread pools.
src/openms/include/OpenMS/CONCEPT/LogStream.h (3)
494-515: Document performance implications of macro function calls.The macros now expand to function calls (
getThreadLocalLogFatal(), etc.) instead of direct global variable access. While this fixes data races, it introduces function call overhead on every log statement.Please verify:
- Has the performance impact been measured, especially in tight loops with frequent logging?
- Are the accessor functions inlined by the compiler to mitigate overhead?
- Should there be guidance for performance-critical code sections (e.g., "minimize logging in hot paths")?
Based on coding guidelines: "Consider algorithmic complexity for data processing operations" and "Be mindful of memory usage when processing large datasets."
434-440: LGTM! Well-documented new method.The
flushIncomplete()method is properly documented with Doxygen format, including a clear@briefdescription explaining its purpose for thread-local logging buffer management.
104-114: Add proper Doxygen documentation for the new constructor.The new constructor has explanatory comments but is missing required Doxygen
@paramtags for its parameters. As a public API addition, it should follow the established documentation format.📝 Suggested documentation format
/** - Create a LogStreamBuf that copies the stream_list_ configuration from another LogStreamBuf. + @brief Create a LogStreamBuf that copies the stream_list_ configuration from another LogStreamBuf. This constructor is used for thread-local logging where each thread has its own buffer and stream configuration (for thread safety), but starts with the same initial configuration as the global LogStream instances. - @param[in] source_buf The LogStreamBuf whose stream_list_ should be copied - @param[in] col If messages should be colored, provide a colorizer here + @param source_buf The LogStreamBuf whose stream_list_ should be copied + @param col If messages should be colored, provide a colorizer here (default nullptr) */Based on coding guidelines: "Use Doxygen documentation with
/** */block comments and@tags;@briefis required" and "Include@param[in],@param[out], or@param[in,out]direction tags for all method parameters."⛔ Skipped due to learnings
Learnt from: CR Repo: OpenMS/OpenMS PR: 0 File: AGENTS.md:0-0 Timestamp: 2026-01-07T06:33:27.218Z Learning: Applies to src/openms/include/**/*.{h,hpp,hxx} : Use Doxygen documentation with `/** */` block comments and `@` tags (not `\` backslash); `brief` is requiredLearnt from: CR Repo: OpenMS/OpenMS PR: 0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-08-05T12:43:11.681Z Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
| OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogFatal(); | ||
|
|
||
| /// @brief Get thread-local error log stream | ||
| OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogError(); | ||
|
|
||
| /// @brief Get thread-local warning log stream | ||
| OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogWarn(); | ||
|
|
||
| /// @brief Get thread-local info log stream | ||
| OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogInfo(); | ||
|
|
||
| /// @brief Get thread-local debug log stream | ||
| OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogDebug(); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add proper Doxygen documentation for thread-local accessor functions.
These public OPENMS_DLLAPI functions have brief comments but are missing proper Doxygen /** @brief ... */ documentation as required by the coding guidelines for public API additions.
📝 Suggested documentation format
-/// @brief Get thread-local fatal error log stream
+/**
+ @brief Get thread-local fatal error log stream
+
+ Returns a thread-local LogStream instance for fatal errors. Each thread gets
+ its own buffer and state. The stream configuration is initialized from the
+ global OpenMS_Log_fatal stream on first access per thread.
+
+ @return Reference to the thread-local fatal error log stream
+*/
OPENMS_DLLAPI Logger::LogStream& getThreadLocalLogFatal();Apply similar documentation to the other four accessor functions.
Based on coding guidelines: "Add Doxygen comments for new public methods" and "Use Doxygen documentation with /** */ block comments and @ tags; @brief is required."
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In @src/openms/include/OpenMS/CONCEPT/LogStream.h around lines 475 - 487, The
five thread-local log accessor functions (getThreadLocalLogFatal,
getThreadLocalLogError, getThreadLocalLogWarn, getThreadLocalLogInfo,
getThreadLocalLogDebug) lack proper Doxygen block comments; add a /** @brief ...
*/ Doxygen comment block above each OPENMS_DLLAPI declaration describing the
purpose (e.g., returns the thread-local LogStream for
fatal/error/warn/info/debug messages) and include any relevant tags such as
@return Logger::LogStream& to match the project’s public API documentation
style.
|
How about using a logging library then? Do we really need this weird log line deduplication functionality that makes multithreading even more complex? We could have Boost.log "for free". |
Simplification CompleteBased on @cbielow's feedback, I've simplified the implementation from Logger::LogStream& getThreadLocalLogFatal()
{
thread_local Logger::LogStream tls(new Logger::LogStreamBuf(OpenMS_Log_fatal.rdbuf(), &red), true);
return tls;
}
// ... same pattern for error, warn, info, debugWhat changed:
Documented restrictions (in LogStream.h):
Test results:
Note on performance:The main benefit is correctness (fixing data races from issue #8596), not speed. With shared stdout, writes still serialize at the OS level. Each thread can now buffer in parallel, but the real win is eliminating undefined behavior from the original race conditions on |
|
Would be interesting to see what happens if you merge this in the PR with the segfaults. Test looks similar (slightly faster if not noise). |
|
I can try that. No strong opinion on merging or not. Interestingly I had a bug in this PR that als triggered a segfault in Param_test. So there is a Chance … |
|
Superseded |
…zations (PR #8582) (#8620) * perf: replace std::endl with '\n' in high-impact files to improve I/O performance Replace ~705 occurrences of std::endl with '\n' in 35 high-impact source files. std::endl flushes the stream buffer after each newline, which is particularly expensive on Windows console I/O. This change addresses issue #4854 by reducing unnecessary stream flushing in logging and debug output paths. Key files updated: - FeatureFinderAlgorithmPicked.cpp (68 occurrences) - PeakPickerIM.cpp (49 occurrences) - Param.cpp (41 occurrences) - TransitionTSVFile.cpp (38 occurrences) - ClassTest.cpp (30 occurrences) - Plus 30 additional high-impact files This optimization should improve test execution times, especially in debug mode on Windows where console I/O is significantly slower. * perf: keep std::endl for error/warning messages to ensure immediate output Selectively revert std::endl to '\n' replacement for error and warning messages that should be immediately visible for debugging. This ensures critical error output is flushed immediately while keeping '\n' for high-frequency debug/info logging. Files with reverted error messages: - HyperScore.cpp: Error/Warning messages for spectrum validation - Param.cpp: Parameter validation errors - IndexedMzMLDecoder.cpp: File parsing errors - FeatureFinderAlgorithmPicked.cpp: Algorithm errors - MSNumpressCoder.cpp: Encoding exceptions - File.cpp: File operation errors/warnings - SwathFile.cpp: File loading warnings - BayesianProteinInferenceAlgorithm.cpp: Protein annotation errors This maintains the performance benefit for debug logging while ensuring error messages are always visible even if the program crashes. * fix: address code review comments and fix Param_test failure - ConsensusFeature.cpp: Replace remaining std::endl with '\n' in operator<< - XQuestResultXMLFile.cpp: Replace std::cout with OPENMS_LOG_INFO for proper logging (lines 81 and 151) - Param.cpp: Keep std::endl for OPENMS_LOG_WARN messages to ensure proper stream flushing (fixes Param_test SEGFAULT) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Add thread-local logging to fix data races in LogStream (#8596) Implement thread-local LogStream instances to eliminate race conditions that occur when multiple threads use OPENMS_LOG_* macros simultaneously. The race conditions affected sync() method operations on shared buffers, incomplete_line_ state, and log caches. Key changes: - Add ThreadLogContext class providing per-thread LogStream instances - Add _TL (thread-local) and _LEGACY macro variants in LogStream.h - Add OPENMS_THREADLOCAL_LOGGING CMake option (ON by default) - Update LogStream_test to work with both modes - Add comprehensive ThreadLogContext_test with multi-threaded tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * [FIX] Integrate thread-local logging with LogConfigHandler Thread-local logging was not picking up stream configuration changes made via LogConfigHandler or direct stream manipulation. This caused test failures in Param_test and LogConfigHandler_test. Changes: - Add LogStreamBuf constructor to copy stream_list_ from source buffer - Thread-local streams now copy initial config from global streams - Add LogStream::flushIncomplete() to flush unterminated lines - LogConfigHandler::setLogLevel() now flushes thread-local buffers - Update tests to call ThreadLogContext::reset() after config changes - Simplify LogStream_test OpenMP test to avoid stream lifetime issues Co-Authored-By: Claude Opus 4.5 <[email protected]> * [SIMPLIFY] Replace ThreadLogContext with 5 simple functions Address reviewer feedback (cbielow) to simplify thread-local logging: - Remove ThreadLogContext class entirely (~250 lines) - Add 5 simple thread-local accessor functions: - getThreadLocalLogFatal() - getThreadLocalLogError() - getThreadLocalLogWarn() - getThreadLocalLogInfo() - getThreadLocalLogDebug() - Remove OPENMS_THREADLOCAL_LOGGING CMake feature flag - Remove legacy logging macros (always use thread-local now) - Document restrictions: configure logging once at startup, before spawning threads The thread-local streams copy stream_list_ from globals on first access, so configuration propagates to new threads automatically. Tests updated: - LogConfigHandler_test uses global streams directly (tests what LogConfigHandler actually configures) - LogStream_test uses thread-local accessors - Removed ThreadLogContext_test Net change: -660 lines (removed 789, added 129) Co-Authored-By: Claude Opus 4.5 <[email protected]> * Address PR review comments for thread-local logging Changes: - Merge '\n' into string literals for efficiency (cbielow) - Improve LogStream_test.cpp OpenMP test with output capture (cbielow) - Hide global loggers in anonymous namespace, add accessor functions (cbielow) - Replace std::cout/cerr with OPENMS_LOG_* macros (CodeRabbit): - FalseDiscoveryRate.cpp: std::cerr -> OPENMS_LOG_DEBUG - PoseClusteringAffineSuperimposer.cpp: std::cout -> OPENMS_LOG_WARN - IonMobilityScoring.cpp: std::cout -> OPENMS_LOG_ERROR - SwathMapMassCorrection.cpp: std::cout -> OPENMS_LOG_DEBUG - Param.cpp: std::cerr -> OPENMS_LOG_WARN Note: Backward compatibility macros for OpenMS_Log_* are included but may be removed pending cbielow's feedback on the PR. Co-Authored-By: Claude Opus 4.5 <[email protected]> * Remove OpenMS_Log_* backward compat macros, force migration to new API Breaking change: Remove deprecated OpenMS_Log_* macros that were aliasing getGlobalLog*() functions. Code using these macros will now fail to compile, forcing migration to the thread-safe logging API. Migration guide: - For configuration (insert/remove streams): use getGlobalLog*() functions - For actual logging: use OPENMS_LOG_* macros (thread-local, thread-safe) Changes: - Remove backward compatibility macros from LogStream.h - Update 29 source files to use getGlobalLog*() for configuration - Replace std::cout/std::cerr with OPENMS_LOG_* macros - Fix XQuestResultXMLFile.cpp corrupted raw string literals - Update LogStream_test to work with thread-local architecture - Update LogConfigHandler_test to use global streams directly Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add Doxygen documentation for getGlobalLog*() functions Add proper /** @brief ... */ Doxygen blocks with: - @brief describing the purpose - @warning about not using for direct logging - @return documenting the return value - @see referencing the corresponding OPENMS_LOG_* macro - @note for debug stream explaining default disabled state Co-Authored-By: Claude Opus 4.5 <[email protected]> * Add LogSinkGuard RAII class for exception-safe log stream management The manual remove()/insert() pattern around pickExperiment() was not exception-safe - if pickExperiment throws, cout would never be re-inserted into the info log stream. - Add Logger::LogSinkGuard class that re-inserts a stream on scope exit - Update FeatureFinderAlgorithmMetaboIdent to use LogSinkGuard - Update FeatureFinderIdentificationAlgorithm to use std::optional<LogSinkGuard> for conditional logging suppression - Add unit tests for LogSinkGuard covering normal exit, exceptions, and nesting Co-Authored-By: Claude Opus 4.5 <[email protected]> * Internalize remove() in LogSinkGuard for true RAII semantics Address cbielow's code review feedback: LogSinkGuard now calls remove() in its constructor instead of requiring a separate manual call. This: - Eliminates the need to specify the stream twice (DRY) - Prevents sync issues if one occurrence is changed but not the other - Provides true RAII semantics (acquisition in constructor) - Simplifies usage from 2 lines to 1 line Changes: - LogStream.h: Add log_stream_.remove(stream_) to LogSinkGuard constructor - FeatureFinderAlgorithmMetaboIdent.cpp: Remove explicit remove() call - FeatureFinderIdentificationAlgorithm.cpp: Remove explicit remove() call - LogStream_test.cpp: Update tests to reflect new RAII behavior Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This adds thread-local LogStream instances to eliminate data races in the logging system. The race conditions occur because sync() modifies shared state (static buffer, incomplete_line_, log_cache_) without protection.
Key changes:
Each thread now gets its own LogStream instances, eliminating all races:
Users can disable with: cmake -DOPENMS_THREADLOCAL_LOGGING=OFF ..
🤖 Generated with Claude Code
Description
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.