Skip to content

Commit

Permalink
Avoid duplicate log entries (#6222)
Browse files Browse the repository at this point in the history
Previously the logger would have two sinks configured (the default + our custom one). This PR clears the default logger before registering our custom one.

Authors:
  - Jim Crist-Harif (https://github.com/jcrist)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #6222
  • Loading branch information
jcrist authored Jan 15, 2025
1 parent cf259f6 commit f29293f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/cuml/cuml/internals/logger.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ IF GPUBUILD == 1:
cdef cppclass sink_vector:
void push_back(const sink_ptr& sink) except +
void pop_back() except +
void clear()

cdef extern from "cuml/common/logger.hpp" namespace "ML" nogil:
cdef cppclass logger:
Expand Down
3 changes: 2 additions & 1 deletion python/cuml/cuml/internals/logger.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,6 @@ def flush():


IF GPUBUILD == 1:
# Set callback functions to handle redirected sys.stdout in Python
# Clear existing sinks and add a callback sink to redirect to sys.stdout
default_logger().sinks().clear()
default_logger().sinks().push_back(<sink_ptr> make_shared[callback_sink_mt](_log_callback, _log_flush))

0 comments on commit f29293f

Please sign in to comment.