diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 326385f16..eba3f122b 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -96,6 +96,11 @@ struct bytes { } }; +inline spdlog::logger& logger() +{ + static detail::logger_wrapper wrapped{}; + return wrapped.logger_; +} } // namespace detail /** @@ -107,10 +112,12 @@ struct bytes { * * @return spdlog::logger& The logger. */ -RMM_EXPORT inline spdlog::logger& logger() +[[deprecated( + "Support for direct access to spdlog loggers in rmm is planned for " + "removal")]] RMM_EXPORT inline spdlog::logger& +logger() { - static detail::logger_wrapper wrapped{}; - return wrapped.logger_; + return detail::logger(); } //! @cond Doxygen_Suppress @@ -118,12 +125,12 @@ RMM_EXPORT inline spdlog::logger& logger() // The default is INFO, but it should be used sparingly, so that by default a log file is only // output if there is important information, warnings, errors, and critical failures // Log messages that require computation should only be used at level TRACE and DEBUG -#define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::logger(), __VA_ARGS__) +#define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::detail::logger(), __VA_ARGS__) //! @endcond diff --git a/python/rmm/rmm/librmm/_logger.pxd b/python/rmm/rmm/librmm/_logger.pxd index 241a748c3..fb2126b2f 100644 --- a/python/rmm/rmm/librmm/_logger.pxd +++ b/python/rmm/rmm/librmm/_logger.pxd @@ -62,5 +62,5 @@ cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: bool should_log(logging_level msg_level) -cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: +cdef extern from "rmm/logger.hpp" namespace "rmm::detail" nogil: cdef spdlog_logger& logger() except + diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index acd540ae6..3fce55fb8 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -204,8 +204,8 @@ TEST(TrackingTest, LogOutstandingAllocations) { std::ostringstream oss; auto oss_sink = std::make_shared(oss); - rmm::logger().sinks().push_back(oss_sink); - auto old_level = rmm::logger().level(); + rmm::detail::logger().sinks().push_back(oss_sink); + auto old_level = rmm::detail::logger().level(); tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; @@ -213,7 +213,7 @@ TEST(TrackingTest, LogOutstandingAllocations) allocations.push_back(mr.allocate(ten_MiB)); } - rmm::logger().set_level(spdlog::level::debug); + rmm::detail::logger().set_level(spdlog::level::debug); EXPECT_NO_THROW(mr.log_outstanding_allocations()); #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG @@ -224,8 +224,8 @@ TEST(TrackingTest, LogOutstandingAllocations) mr.deallocate(allocation, ten_MiB); } - rmm::logger().set_level(old_level); - rmm::logger().sinks().pop_back(); + rmm::detail::logger().set_level(old_level); + rmm::detail::logger().sinks().pop_back(); } } // namespace