Skip to content

[FEATURE] Add thread-local logging to fix data races (issue #8596) - #8610

Closed
timosachsenberg wants to merge 3 commits into
developfrom
feature/thread-local-logging
Closed

timosachsenberg wants to merge 3 commits into
developfrom
feature/thread-local-logging

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Add ThreadLogContext class with thread-local storage for log streams
  • Add OPENMS_LOG_*_TL macros for direct thread-local access
  • Add OPENMS_THREADLOCAL_LOGGING CMake option (enabled by default)
  • When enabled, OPENMS_LOG_* macros use thread-local streams
  • Update LogStream_test to work with both modes
  • Add comprehensive ThreadLogContext_test

Each thread now gets its own LogStream instances, eliminating all races:

  • static char buf[] - each thread has own buffer
  • incomplete_line_ - each thread has own string
  • log_cache_/log_time_cache_ - each thread has own caches

Users can disable with: cmake -DOPENMS_THREADLOCAL_LOGGING=OFF ..

🤖 Generated with Claude Code

Description

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

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.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • New Features

    • Added thread-local logging support with dedicated per-thread log stream instances.
    • Introduced new flushIncomplete() methods to properly handle buffered incomplete lines.
    • Enhanced logging configuration via new public stream accessors and exports.
  • Tests

    • Expanded test coverage for thread-local and global stream logging behavior.
  • Chores

    • Updated logging macros to support both thread-local and legacy logging paths.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
LogStream API & Infrastructure
src/openms/include/OpenMS/CONCEPT/LogStream.h, src/openms/source/CONCEPT/LogStream.cpp
Adds copy constructor for LogStreamBuf (LogStreamBuf(LogStreamBuf* source_buf, Colorizer* col)), exposes stream-list via getStreamList_() accessors, introduces flushIncomplete() for flushing partial lines. Adds thread-local log accessor functions, updates macros to support both global and thread-local logging paths, includes new public externs for OpenMS_Log_info and OpenMS_Log_debug.
Test Updates - Macros & Thread-Local
src/tests/class_tests/openms/source/LogStream_test.cpp
Updates logging macro tests (OPENMS_LOG_FATAL_ERROR, OPENMS_LOG_ERROR, OPENMS_LOG_WARN, OPENMS_LOG_INFO, OPENMS_LOG_DEBUG) to use thread-local logger management with clearCache(), removeAllStreams(), and getThreadLocalLogX() calls instead of direct global stream manipulation. Adjusts OpenMP test to remove stream setup and adds explanatory comments about thread-local lifetime concerns.
Test Updates - Global Stream References
src/tests/class_tests/openms/source/LogConfigHandler_test.cpp, src/tests/class_tests/openms/source/Param_test.cpp
Replaces usage of OPENMS_LOG_* and OpenMS_Log_* references with new global stream names (OpenMS_Log_info, OpenMS_Log_warn, OpenMS_Log_error). Updates Param_test to configure thread-local warn stream via getThreadLocalLogWarn(). Adds comments clarifying global vs. thread-local stream usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • jpfeuffer

Poem

🐰 Threads now whisper logs so clear,
Each bunny thread with streams so dear,
No more races in the night,
Per-thread buffers, oh what delight!
Flushing incomplete with gentle care,
LogStreams dancing everywhere! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main feature being added: thread-local logging to address data races in the logging system (issue #8596).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.h is placed between Macros.h and MacrosTest.h. For consistency with the alphabetical ordering, it should be positioned after Types.h (line 26) and before UniqueIdGenerator.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.cpp is placed between PrecisionWrapper.cpp and ProgressLogger.cpp. For consistency with the alphabetical ordering, it should be positioned after Types.cpp (line 21) and before UniqueIdGenerator.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_TL is 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(). The isInitialized(), ensureInitialized(), reset(), and flushAll() methods properly handle the optional nature of tls_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() calls ensureInitialized() when tls_streams is null).

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91afebf and 5de3013.

📒 Files selected for processing (11)
  • CMakeLists.txt
  • doc/thread-local-logging-plan.md
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/config.h.in
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/source/CONCEPT/sources.cmake
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.h
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • 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/ThreadLogContext.h
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{cpp,cc,cxx,h,hpp,hxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx,h,hpp,hxx}: Never use std::endl; use \n for 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; prefer enum class over macro constants

Files:

  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{h,hpp,hxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{h,hpp,hxx}: Never add using namespace or using std::... in header files; allowed in .cpp files 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.h
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.{h,hpp,hxx}

📄 CodeRabbit inference engine (AGENTS.md)

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
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); @brief is 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.h
  • 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}: Prefer OpenMS::String for numeric formatting and parsing instead of standard stream operators
Use Size/SignedSize types for STL .size() values instead of raw integers
Use OpenMS primitive types from OpenMS/CONCEPT/Types.h
Derive custom exceptions from Exception::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
Use OpenMS/CONCEPT/Types.h primitive 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.h
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • 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/ThreadLogContext.h
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
src/openms/include/**/*.h

📄 CodeRabbit inference engine (AGENTS.md)

Use templates with _impl.h only when needed; .h files must not include _impl.h

Files:

  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
**/*.{cpp,cc,cxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx}: Never use std::cout or std::cerr directly; 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.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/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: Use START_SECTION and END_SECTION macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Use NEW_TMP_FILE macro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used with START_SECTION macro

Files:

  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/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 of std::cout or std::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.in
  • CMakeLists.txt
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • doc/thread-local-logging-plan.md
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/openms/source/CONCEPT/sources.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/**/*.{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.in
  • CMakeLists.txt
  • doc/thread-local-logging-plan.md
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/openms/source/CONCEPT/sources.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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 **/*.{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.in
  • CMakeLists.txt
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/config.h.in
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • 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/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.in
  • src/tests/class_tests/openms/executables.cmake
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/source/CONCEPT/sources.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/**/*.{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.in
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/openms/source/CONCEPT/sources.cmake
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • 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/config.h.in
  • 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} : 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.in
  • 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 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.in
  • CMakeLists.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.cmake
  • src/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.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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
  • CMakeLists.txt
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • 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/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`

Applied to files:

  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • 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/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.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/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
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • src/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.cmake
  • src/tests/class_tests/openms/source/ThreadLogContext_test.cpp
  • 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/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.cmake
  • src/openms/source/CONCEPT/sources.cmake
  • 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 : 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.cmake
  • src/openms/source/CONCEPT/sources.cmake
  • 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/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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 ON is 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_test to Boost_dependent_tests is consistent with LogStream_test also 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 1 correctly aligns with the CMake option default of ON, 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_TEST and END_TEST.


38-72: Good coverage of basic log stream accessors.

These tests correctly verify that each ThreadLogContext accessor returns a LogStream with the expected level. The tests are concise and follow the START_SECTION/END_SECTION pattern.


74-105: Good lifecycle method coverage.

The tests for isInitialized(), ensureInitialized(), reset(), and flushAll() properly verify the initialization state and that these methods don't crash. Using NOT_TESTABLE for flushAll() is appropriate since it has no observable return value.


146-193: Solid multi-threaded test with proper synchronization.

The use of std::atomic for completed_count and has_own_prefix is 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 _OPENMP and 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 ThreadLogContext accessors without any critical section wrapping, which eliminates the data races. The debug macros properly include file/line information using past_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_DLLAPI export, 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 like ThreadLogConfigManager and 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. The getThreadLogStreams() function provides safe lazy initialization.

A note on the use of std::cout/std::cerr at 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.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

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]>
@timosachsenberg
timosachsenberg force-pushed the feature/thread-local-logging branch from 5de3013 to 7f60b9a Compare January 7, 2026 16:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5de3013 and 7f60b9a.

📒 Files selected for processing (10)
  • CMakeLists.txt
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/openms/include/OpenMS/CONCEPT/ThreadLogContext.h
  • src/openms/include/OpenMS/CONCEPT/sources.cmake
  • src/openms/include/OpenMS/config.h.in
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/source/CONCEPT/sources.cmake
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
**/*.{cpp,cc,cxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx}: Never use std::cout or std::cerr directly; 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 use std::endl; use \n for 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; prefer enum class over macro constants

Files:

  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • 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}: Prefer OpenMS::String for numeric formatting and parsing instead of standard stream operators
Use Size/SignedSize types for STL .size() values instead of raw integers
Use OpenMS primitive types from OpenMS/CONCEPT/Types.h
Derive custom exceptions from Exception::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
Use OpenMS/CONCEPT/Types.h primitive 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.cpp
  • src/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.cpp
  • src/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 of std::cout or std::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 add using namespace or using std::... in header files; allowed in .cpp files 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}: Add OPENMS_DLLAPI macro 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); @brief is 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.h only when needed; .h files 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.cpp
  • src/openms/source/CONCEPT/sources.cmake
  • 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/**/*.{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.cpp
  • src/openms/source/CONCEPT/sources.cmake
  • 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 **/*.{cpp,cc,cxx} : Never use `std::cout` or `std::cerr` directly; use OpenMS logging macros instead

Applied to files:

  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • 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/**/*.{cpp,cc,cxx,h,hpp,hxx} : Use OpenMS primitive types from `OpenMS/CONCEPT/Types.h`

Applied to files:

  • src/openms/source/CONCEPT/sources.cmake
  • 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/**/*.{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.cmake
  • 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/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.cmake
  • src/tests/class_tests/openms/executables.cmake
  • 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/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.cmake
  • src/tests/class_tests/openms/executables.cmake
  • 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/topp/**/*.cpp : Use `ProgressLogger` in TOPP tools for progress reporting

Applied to files:

  • src/openms/source/CONCEPT/sources.cmake
  • 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/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.cmake
  • src/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_local for tls_streams ensures each thread gets its own instance, and the lazy initialization in getThreadLogStreams() 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 initialized flag check in isInitialized() 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, and magenta are properly declared with extern OPENMS_DLLAPI in src/openms/include/OpenMS/CONCEPT/Colorizer.h (lines 202, 204, 206) and defined in src/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 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Keep ThreadLogContext but remove all legacy code paths (~135 lines deleted, class stays)
  2. 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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f60b9a and 4019b9d.

📒 Files selected for processing (7)
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/openms/source/CONCEPT/LogStream.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
**/*.{cpp,cc,cxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx}: Never use std::cout or std::cerr directly; 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.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/source/CONCEPT/LogStream.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx,h,hpp,hxx}: Never use std::endl; use \n for 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; prefer enum class over macro constants

Files:

  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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: Use START_SECTION and END_SECTION macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Use NEW_TMP_FILE macro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used with START_SECTION macro

Files:

  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/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.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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}: Prefer OpenMS::String for numeric formatting and parsing instead of standard stream operators
Use Size/SignedSize types for STL .size() values instead of raw integers
Use OpenMS primitive types from OpenMS/CONCEPT/Types.h
Derive custom exceptions from Exception::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
Use OpenMS/CONCEPT/Types.h primitive 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.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/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.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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 of std::cout or std::cerr

Files:

  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/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 add using namespace or using std::... in header files; allowed in .cpp files 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}: Add OPENMS_DLLAPI macro 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); @brief is 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.h only when needed; .h files 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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`

Applied to files:

  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • 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} : Utilize OpenMS logging mechanisms

Applied to files:

  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • 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/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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • 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} : 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.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/openms/source/CONCEPT/ThreadLogContext.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/**/*.{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.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/**/*.{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.cpp
  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/**/*.{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.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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} : Use appropriate OpenMS containers and algorithms

Applied to files:

  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/tests/class_tests/openms/source/Param_test.cpp
  • 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} : Use `OpenMS/CONCEPT/Types.h` primitive types instead of standard C++ types for consistency

Applied to files:

  • src/openms/source/CONCEPT/LogConfigHandler.cpp
  • src/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_warn

The 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.h is 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 documentation
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

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_LOGGING is 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

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

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 ThreadLogContext class exists primarily for three functions that simple standalone functions can't provide:

1. flushAll() - Called Before Log Reconfiguration

Used in LogConfigHandler.cpp before reconfiguring log streams. Flushes incomplete lines (text without \n) from ALL thread-local buffers.

Without it: If a thread is mid-line when LogConfigHandler reconfigures streams, partial output could be lost or garbled. This is a rare edge case though.

2. reset() - Test Isolation (Most Important)

Used in LogStream_test.cpp, LogConfigHandler_test.cpp, and Param_test.cpp to destroy thread-local instances between tests.

Without it: Test pollution - one test's log configuration leaks into subsequent tests, causing flaky/non-deterministic test results. Tests redirect log streams to capture output, and without reset, those redirects persist.

3. isInitialized() / ensureInitialized() - Lifecycle Management

Ensures thread-local streams copy the current global configuration when created.

Without it: Edge cases where configuration timing matters might behave unexpectedly.


Summary

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:

  1. Keep ThreadLogContext as-is (current approach)
  2. Simplify to functions + add a thread_local bool reset flag for tests
  3. Simplify to functions and accept test isolation challenges

Let me know your preference and I can refactor accordingly.

@cbielow

cbielow commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

these are good points, let me address them:

1. flushAll() - Called Before Log Reconfiguration
Used in LogConfigHandler.cpp before reconfiguring log streams. Flushes incomplete lines (text without \n) from ALL thread-local buffers.
Without it: If a thread is mid-line when LogConfigHandler reconfigures streams, partial output could be lost or garbled. This is a rare edge case though.

This should not be a supported use-case. Log configuration should be done once in the beginning globally, and then copied by all threads.

2. reset() - Test Isolation (Most Important)

Used in LogStream_test.cpp, LogConfigHandler_test.cpp, and Param_test.cpp to destroy thread-local instances between tests.

Without it: Test pollution - one test's log configuration leaks into subsequent tests, causing flaky/non-deterministic test results. Tests redirect log streams to capture output, and without reset, those redirects persist.
3. isInitialized() / ensureInitialized() - Lifecycle Management

Ensures thread-local streams copy the current global configuration when created.

What prevents you from resetting the thread_local streams in the tests?
Also, consider that a thread-pool, used by OpenMP and others, will re-use the same thread_local variable across different parallel regions (just tested this manually), i.e. one cannot expect a new vanilla thread in a parallel region!

@cbielow

cbielow commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

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.

@cbielow

cbielow commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

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).

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 calling remove(), 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4019b9d and b2353ab.

📒 Files selected for processing (5)
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/openms/source/CONCEPT/LogStream.cpp
  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/tests/class_tests/openms/source/LogConfigHandler_test.cpp
**/*.{cpp,cc,cxx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{cpp,cc,cxx}: Never use std::cout or std::cerr directly; 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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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 use std::endl; use \n for 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; prefer enum class over macro constants

Files:

  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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: Use START_SECTION and END_SECTION macros in C++ unit tests; wrap template methods with 2+ arguments in parentheses
Use NEW_TMP_FILE macro for each output file in tests to avoid side effects
Wrap template methods with 2+ arguments in parentheses when used with START_SECTION macro

Files:

  • src/tests/class_tests/openms/source/Param_test.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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 add using namespace or using std::... in header files; allowed in .cpp files 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}: Add OPENMS_DLLAPI macro 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); @brief is 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}: Prefer OpenMS::String for numeric formatting and parsing instead of standard stream operators
Use Size/SignedSize types for STL .size() values instead of raw integers
Use OpenMS primitive types from OpenMS/CONCEPT/Types.h
Derive custom exceptions from Exception::Base; throw with file/line/OPENMS_PRETTY_FUNCTION; catch by reference
Avoid pointers; prefer references in C++ code
Use OpenMS/CONCEPT/Types.h primitive 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.h only when needed; .h files 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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • 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/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • 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/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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 **/*.{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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • src/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/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.cpp
  • src/tests/class_tests/openms/source/LogStream_test.cpp
  • 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/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.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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.cpp
  • src/openms/include/OpenMS/CONCEPT/LogStream.h
  • src/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_warn stream to using the thread-local accessor getThreadLocalLogWarn(). 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 because LogConfigHandler configures 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:

  1. Has the performance impact been measured, especially in tight loops with frequent logging?
  2. Are the accessor functions inlined by the compiler to mitigate overhead?
  3. 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 @brief description 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 @param tags 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; @brief is 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 required
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

Comment on lines +475 to +487
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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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.

@jpfeuffer

Copy link
Copy Markdown
Contributor

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".
But yeah I'd rather fix it here if not too complex.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Simplification Complete

Based on @cbielow's feedback, I've simplified the implementation from ThreadLogContext class to 5 simple functions:

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, debug

What changed:

  • Removed ThreadLogContext class entirely (~250 lines)
  • Removed OPENMS_THREADLOCAL_LOGGING CMake feature flag
  • Removed legacy macros - thread-local is now the only implementation
  • Added 5 simple accessor functions (~35 lines)
  • Net change: -660 lines

Documented restrictions (in LogStream.h):

  • Log configuration should be done ONCE at program start, BEFORE spawning threads
  • Thread-local streams copy config from globals on first access
  • OpenMP thread pools reuse threads, so thread_local state persists across parallel regions

Test results:

  • ✅ LogStream_test: Passed
  • ✅ LogConfigHandler_test: Passed (updated to test global streams directly)
  • ✅ 99% of all tests pass (2428/2437) - failures unrelated to logging

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 static char buf[], incomplete_line_, and cache maps.

@jpfeuffer

jpfeuffer commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Would be interesting to see what happens if you merge this in the PR with the segfaults.
Or would you want to merge it anyway?
Have you compared the testing times for example?

Test looks similar (slightly faster if not noise).

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

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 …

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Superseded

timosachsenberg added a commit that referenced this pull request Jan 12, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants