19 #include <fmt/format.h>
20 #include <fmt/ostream.h>
21 #include <spdlog/sinks/basic_file_sink.h>
22 #include <spdlog/spdlog.h>
40 inline std::string default_log_filename()
42 auto* filename = std::getenv(
"RMM_DEBUG_LOG_FILE");
43 return (filename ==
nullptr) ? std::string{
"rmm_log.txt"} : std::string{filename};
54 std::make_shared<spdlog::sinks::basic_file_sink_mt>(
55 default_log_filename(), true
58 logger_.set_pattern(
"[%6t][%H:%M:%S:%f][%-6l] %v");
59 logger_.flush_on(spdlog::level::warn);
60 #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO
61 #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
62 logger_.info(
"----- RMM LOG BEGIN [PTDS ENABLED] -----");
64 logger_.info(
"----- RMM LOG BEGIN [PTDS DISABLED] -----");
85 static std::array units{
"B",
"KiB",
"MiB",
"GiB",
"TiB",
"PiB",
"EiB",
"ZiB",
"YiB"};
88 auto size =
static_cast<double>(
value.value);
93 return os << size <<
' ' << units.at(index);
119 #define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::logger(), __VA_ARGS__)
120 #define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::logger(), __VA_ARGS__)
121 #define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::logger(), __VA_ARGS__)
122 #define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::logger(), __VA_ARGS__)
123 #define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::logger(), __VA_ARGS__)
124 #define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::logger(), __VA_ARGS__)
133 struct fmt::formatter<rmm::detail::bytes> : fmt::ostream_formatter {};
spdlog::logger & logger()
Returns the global RMM logger.
Definition: logger.hpp:108
Represent a size in number of bytes.
Definition: logger.hpp:74
friend std::ostream & operator<<(std::ostream &os, bytes const &value)
Construct a new bytes object.
Definition: logger.hpp:83
std::size_t value
The size in bytes.
Definition: logger.hpp:75
Simple wrapper around a spdlog::logger that performs RMM-specific initialization.
Definition: logger.hpp:49
spdlog::logger logger_
The underlying logger.
Definition: logger.hpp:50