-
Notifications
You must be signed in to change notification settings - Fork 222
refactor(logger): give each component library its own logger #1778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ramakrishnap-nv
wants to merge
1
commit into
main
Choose a base branch
from
refactor/per-library-logger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| #include <utilities/logger.hpp> | ||
|
|
||
| /* | ||
| * The logger itself is header-only and hidden, so it is private to each component library. | ||
| * This translation unit is compiled into cuopt_mathopt only, which is what makes the | ||
| * functions below reach mathopt's instance and no other. | ||
| */ | ||
| namespace cuopt::mathematical_optimization { | ||
|
|
||
| void configure_logging(const std::string& log_file, bool log_to_console, bool truncate) | ||
| { | ||
| cuopt::configure_logging_impl(log_file, log_to_console, truncate); | ||
| } | ||
|
|
||
| void reset_logging() { cuopt::reset_logging_impl(); } | ||
|
|
||
| } // namespace cuopt::mathematical_optimization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| #include <utilities/logger.hpp> | ||
|
|
||
| /* | ||
| * The logger itself is header-only and hidden, so it is private to each component library. | ||
| * This translation unit is compiled into cuopt_routing only, which is what makes the | ||
| * functions below reach routing's instance and no other. | ||
| */ | ||
| namespace cuopt::routing { | ||
|
|
||
| void configure_logging(const std::string& log_file, bool log_to_console, bool truncate) | ||
| { | ||
| cuopt::configure_logging_impl(log_file, log_to_console, truncate); | ||
| } | ||
|
|
||
| void reset_logging() { cuopt::reset_logging_impl(); } | ||
|
|
||
| } // namespace cuopt::routing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 150
🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 50370
🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 50368
🌐 Web query:
CMake $<TARGET_OBJECTS:object-library> usage requirements compile definitions are not propagated💡 Result:
The behavior where compile definitions (and other usage requirements) attached to an Object Library do not seem to propagate is often misunderstood because of how Object Libraries handle their own object files versus their usage requirements [1][2][3][4]. Key Technical Points: 1. Usage Requirements Do Propagate: Unlike the object files themselves, the usage requirements (such as compile definitions, include directories, and compile options) attached to an Object Library via commands like target_compile_definitions(target PUBLIC...) do propagate to targets that link to the Object Library using target_link_libraries [1][2][3][4]. 2. Object Files Do Not Propagate: The primary limitation is that an Object Library's compiled object files do not propagate transitively through other libraries [1][2][3]. If Target A depends on Object Library B, and Target C links to Target A, Target C will receive the usage requirements of Object Library B, but it will not automatically include the object files from Object Library B [1][5][3]. Only targets that link directly to an Object Library receive its object files [3][4]. 3. Common Misconception: If your compilation is failing to see a definition, verify how you are "linking" the Object Library. You must use target_link_libraries(consuming_target PUBLIC/PRIVATE object_lib) for the usage requirements to be applied to the consuming target [1][2][6]. Simply adding$<TARGET_OBJECTS:object_lib> as a source to a target does not automatically associate the usage requirements of the object library with that target [1][2]. Recommended Workarounds: * Use an INTERFACE Library: To bundle both the object files and the usage requirements for transitive propagation, create an INTERFACE library [1][5][2]. You can set the interface library's requirements and use it to forward the object files [1][2]: add_library(iface_lib INTERFACE) target_link_libraries(iface_lib INTERFACE obj_lib) target_sources(iface_lib INTERFACE $ <TARGET_OBJECTS:obj_lib>) Then, link your final executable or library to iface_lib [1][2]. * Direct Linking: If you do not require transitive propagation through intermediate libraries, ensure that every target that needs the object files (and their associated compile definitions) links directly to the Object Library using target_link_libraries [1][3]. This behavior is by design in CMake to avoid duplicate symbols and manage dependency graphs, rather than a bug [3][4]. If you require the behavior of a standard library where dependencies propagate automatically, a static library is generally preferred over an Object Library [4].
Citations:
Propagate
CUOPT_HAS_ROUTINGtocuoptandcuopt_static.cuopt_cliand the tests link these targets through$<TARGET_OBJECTS:cuopt_objs>, which does not propagatecuopt_objsusage requirements. Without the definition, the routing branch ininit_component_logger_tis a no-op.🤖 Prompt for AI Agents