From 60f6157234c9dc8f27ea54f7d605600cca1deae8 Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:30:52 -0800 Subject: [PATCH 01/37] remove unused function --- cpp/src/io/utilities/config_utils.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cpp/src/io/utilities/config_utils.cpp b/cpp/src/io/utilities/config_utils.cpp index 2d1da31a08f..0f8961334cf 100644 --- a/cpp/src/io/utilities/config_utils.cpp +++ b/cpp/src/io/utilities/config_utils.cpp @@ -23,12 +23,6 @@ namespace cudf::io::detail { -std::string getenv_or(std::string const& env_var_name, std::string_view default_val) -{ - auto const env_val = std::getenv(env_var_name.c_str()); - return std::string{(env_val == nullptr) ? default_val : env_val}; -} - namespace cufile_integration { namespace { From a888ac8bd3f0c3496a00967f4b15636e44fc9c99 Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:37:59 -0800 Subject: [PATCH 02/37] logger --- cpp/include/cudf/utilities/logger.hpp | 107 ++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 cpp/include/cudf/utilities/logger.hpp diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp new file mode 100644 index 00000000000..eb7a3c73249 --- /dev/null +++ b/cpp/include/cudf/utilities/logger.hpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// If using GCC, temporary workaround for older libcudacxx defining _LIBCPP_VERSION +// undefine it before including spdlog, due to fmtlib checking if it is defined +// TODO: remove once libcudacxx is on Github and RAPIDS depends on it +#ifdef __GNUG__ +#undef _LIBCPP_VERSION +#endif +#include +#include + +#include +#include + +namespace cudf { + +namespace detail { + +/** + * @brief Returns the default log filename for the global logger. + * + * If the environment variable `CUDF_DEBUG_LOG_FILE` is defined, its value is used as the path and + * name of the log file. Otherwise, the file `cudf_log.txt` in the current working directory is + * used. + * + * @return std::string The default log file name. + */ +inline std::string default_log_filename() +{ + auto* filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); + return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; +} + +// Simple wrapper around a spdlog::logger that performs cuDF-specific initialization +struct logger_wrapper { + spdlog::logger logger_; + + spdlog::level::level_enum spdlog_level_from_string(std::string_view str) + { + if (str == "TRACE") return spdlog::level::trace; + if (str == "DEBUG") return spdlog::level::debug; + if (str == "INFO") return spdlog::level::info; + if (str == "WARN") return spdlog::level::warn; + if (str == "ERR") return spdlog::level::err; + if (str == "CRITICAL") return spdlog::level::critical; + if (str == "OFF") return spdlog::level::off; + + // keep the default if the env var is invalid + return spdlog::level::info; + } + + logger_wrapper() + : logger_{"CUDF", + std::make_shared( + default_log_filename(), true // truncate file + )} + { + logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); + logger_.flush_on(spdlog::level::warn); + + auto const env_level = std::getenv("LIBCUDF_LOGGING_LEVEL"); + if (env_level != nullptr) { logger_.set_level(spdlog_level_from_string(env_level)); } + } +}; + +} // namespace detail + +/** + * @brief Returns the global logger + * + * This is a spdlog logger. The easiest way to log messages is to use the `CUDF_LOG_*` macros. + * + * @return spdlog::logger& The logger. + */ +inline spdlog::logger& logger() +{ + static detail::logger_wrapper wrapped{}; + return wrapped.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 CUDF_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_INFO(...) SPDLOG_LOGGER_INFO(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_WARN(...) SPDLOG_LOGGER_WARN(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&cudf::logger(), __VA_ARGS__) + +} // namespace cudf From 51083710f9d540532b816c547d7779506d342397 Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:38:33 -0800 Subject: [PATCH 03/37] log env var reads --- cpp/src/io/utilities/config_utils.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpp/src/io/utilities/config_utils.hpp b/cpp/src/io/utilities/config_utils.hpp index 4f6a14091cf..0aa9a51ada8 100644 --- a/cpp/src/io/utilities/config_utils.hpp +++ b/cpp/src/io/utilities/config_utils.hpp @@ -15,6 +15,8 @@ */ #pragma once +#include + #include #include @@ -28,6 +30,13 @@ template T getenv_or(std::string_view env_var_name, T default_val) { auto const env_val = std::getenv(env_var_name.data()); + if (env_val != nullptr) { + logger().debug("Environment variable {} read as {}", env_var_name, env_val); + } else { + logger().debug( + "Environment variable {} is not set, using default value {}", env_var_name, default_val); + } + if (env_val == nullptr) { return default_val; } std::stringstream sstream(env_val); From b2cc5311472baa21c0c06585eaad60cd963805e6 Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:39:00 -0800 Subject: [PATCH 04/37] remove repeated env var reads of PREFER_PAGEABLE_TMP_MEMORY --- cpp/src/io/utilities/hostdevice_vector.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/src/io/utilities/hostdevice_vector.hpp b/cpp/src/io/utilities/hostdevice_vector.hpp index 01e1616b6e2..5a551998d21 100644 --- a/cpp/src/io/utilities/hostdevice_vector.hpp +++ b/cpp/src/io/utilities/hostdevice_vector.hpp @@ -30,6 +30,13 @@ #include +inline bool hostdevice_vector_uses_pageable_buffer() +{ + static bool const use_pageable = + cudf::io::detail::getenv_or("LIBCUDF_IO_PREFER_PAGEABLE_TMP_MEMORY", 0); + return use_pageable; +} + /** * @brief A helper class that wraps fixed-length device memory for the GPU, and * a mirror host pinned memory for the CPU. @@ -56,9 +63,7 @@ class hostdevice_vector { { CUDF_EXPECTS(initial_size <= max_size, "initial_size cannot be larger than max_size"); - auto const use_pageable_buffer = - cudf::io::detail::getenv_or("LIBCUDF_IO_PREFER_PAGEABLE_TMP_MEMORY", 0); - if (use_pageable_buffer) { + if (hostdevice_vector_uses_pageable_buffer()) { h_data_owner = thrust::host_vector(); } else { h_data_owner = thrust::host_vector>(); From d7ecd335e4d24535acabfd5a2aabbf0e5f98a16c Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:40:05 -0800 Subject: [PATCH 05/37] copyright year --- cpp/src/io/utilities/config_utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/io/utilities/config_utils.hpp b/cpp/src/io/utilities/config_utils.hpp index 0aa9a51ada8..85ff99a99a0 100644 --- a/cpp/src/io/utilities/config_utils.hpp +++ b/cpp/src/io/utilities/config_utils.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 830ab0073714f6a3ad0a2e70debfcb9d9302a000 Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:47:21 -0800 Subject: [PATCH 06/37] docs --- cpp/include/cudf/utilities/logger.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp index eb7a3c73249..79487096ea6 100644 --- a/cpp/include/cudf/utilities/logger.hpp +++ b/cpp/include/cudf/utilities/logger.hpp @@ -47,10 +47,18 @@ inline std::string default_log_filename() return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; } -// Simple wrapper around a spdlog::logger that performs cuDF-specific initialization +/** + * @brief Simple wrapper around a spdlog::logger that performs cuDF-specific initialization. + */ struct logger_wrapper { - spdlog::logger logger_; + spdlog::logger logger_; ///< wrapped `spdlog` logger + /** + * @brief Converts the level name into the `spdlog` level enum. + * + * @param str logging level name + * @return corresponding`spdlog` level enum; info if input string is invalid + */ spdlog::level::level_enum spdlog_level_from_string(std::string_view str) { if (str == "TRACE") return spdlog::level::trace; From a4c51c046b474d756aaed5ffb1a48b1b0fc9ee6b Mon Sep 17 00:00:00 2001 From: vuule Date: Sat, 28 Jan 2023 00:47:27 -0800 Subject: [PATCH 07/37] yaml --- conda/recipes/libcudf/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index d296cf86071..bde074ca72d 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -272,6 +272,7 @@ outputs: - test -f $PREFIX/include/cudf/utilities/bit.hpp - test -f $PREFIX/include/cudf/utilities/default_stream.hpp - test -f $PREFIX/include/cudf/utilities/error.hpp + - test -f $PREFIX/include/cudf/utilities/logger.hpp - test -f $PREFIX/include/cudf/utilities/span.hpp - test -f $PREFIX/include/cudf/utilities/traits.hpp - test -f $PREFIX/include/cudf/utilities/type_checks.hpp From 3d7c2ca8e76bf53c786d93033e3dadae46b1c725 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 30 Jan 2023 17:32:52 -0800 Subject: [PATCH 08/37] move impl to cpp --- cpp/CMakeLists.txt | 1 + cpp/include/cudf/utilities/logger.hpp | 69 +--------------------- cpp/src/utilities/logger.cpp | 85 +++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 68 deletions(-) create mode 100644 cpp/src/utilities/logger.cpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9a9b5d1e5ed..2fbec74759d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -579,6 +579,7 @@ add_library( src/unary/nan_ops.cu src/unary/null_ops.cu src/utilities/default_stream.cpp + src/utilities/logger.cpp src/utilities/traits.cpp src/utilities/type_checks.cpp src/utilities/type_dispatcher.cpp diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp index 79487096ea6..8789b450f91 100644 --- a/cpp/include/cudf/utilities/logger.hpp +++ b/cpp/include/cudf/utilities/logger.hpp @@ -22,73 +22,10 @@ #ifdef __GNUG__ #undef _LIBCPP_VERSION #endif -#include #include -#include -#include - namespace cudf { -namespace detail { - -/** - * @brief Returns the default log filename for the global logger. - * - * If the environment variable `CUDF_DEBUG_LOG_FILE` is defined, its value is used as the path and - * name of the log file. Otherwise, the file `cudf_log.txt` in the current working directory is - * used. - * - * @return std::string The default log file name. - */ -inline std::string default_log_filename() -{ - auto* filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); - return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; -} - -/** - * @brief Simple wrapper around a spdlog::logger that performs cuDF-specific initialization. - */ -struct logger_wrapper { - spdlog::logger logger_; ///< wrapped `spdlog` logger - - /** - * @brief Converts the level name into the `spdlog` level enum. - * - * @param str logging level name - * @return corresponding`spdlog` level enum; info if input string is invalid - */ - spdlog::level::level_enum spdlog_level_from_string(std::string_view str) - { - if (str == "TRACE") return spdlog::level::trace; - if (str == "DEBUG") return spdlog::level::debug; - if (str == "INFO") return spdlog::level::info; - if (str == "WARN") return spdlog::level::warn; - if (str == "ERR") return spdlog::level::err; - if (str == "CRITICAL") return spdlog::level::critical; - if (str == "OFF") return spdlog::level::off; - - // keep the default if the env var is invalid - return spdlog::level::info; - } - - logger_wrapper() - : logger_{"CUDF", - std::make_shared( - default_log_filename(), true // truncate file - )} - { - logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); - logger_.flush_on(spdlog::level::warn); - - auto const env_level = std::getenv("LIBCUDF_LOGGING_LEVEL"); - if (env_level != nullptr) { logger_.set_level(spdlog_level_from_string(env_level)); } - } -}; - -} // namespace detail - /** * @brief Returns the global logger * @@ -96,11 +33,7 @@ struct logger_wrapper { * * @return spdlog::logger& The logger. */ -inline spdlog::logger& logger() -{ - static detail::logger_wrapper wrapped{}; - return wrapped.logger_; -} +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 diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp new file mode 100644 index 00000000000..1459989cb7e --- /dev/null +++ b/cpp/src/utilities/logger.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +#include +#include + +namespace cudf { + +/** + * @brief Returns the default log filename for the global logger. + * + * If the environment variable `CUDF_DEBUG_LOG_FILE` is defined, its value is used as the path and + * name of the log file. Otherwise, the file `cudf_log.txt` in the current working directory is + * used. + * + * @return std::string The default log file name. + */ +inline std::string default_log_filename() +{ + auto* filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); + return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; +} + +/** + * @brief Simple wrapper around a spdlog::logger that performs cuDF-specific initialization. + */ +struct logger_wrapper { + spdlog::logger logger_; + + /** + * @brief Converts the level name into the `spdlog` level enum. + */ + spdlog::level::level_enum spdlog_level_from_string(std::string_view str) + { + if (str == "TRACE") return spdlog::level::trace; + if (str == "DEBUG") return spdlog::level::debug; + if (str == "INFO") return spdlog::level::info; + if (str == "WARN") return spdlog::level::warn; + if (str == "ERR") return spdlog::level::err; + if (str == "CRITICAL") return spdlog::level::critical; + if (str == "OFF") return spdlog::level::off; + + CUDF_FAIL("Invalid value for LIBCUDF_LOGGING_LEVEL environment variable"); + } + + logger_wrapper() + : logger_{"CUDF", + std::make_shared( + default_log_filename(), true // truncate file + )} + { + logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); + logger_.flush_on(spdlog::level::warn); + + auto const env_level = std::getenv("LIBCUDF_LOGGING_LEVEL"); + if (env_level != nullptr) { logger_.set_level(spdlog_level_from_string(env_level)); } + } +}; + +spdlog::logger& logger() +{ + static logger_wrapper wrapped{}; + return wrapped.logger_; +} + +} // namespace cudf From 0df8e97ca0d0a8ed0cf4a417b57b766d70125588 Mon Sep 17 00:00:00 2001 From: vuule Date: Thu, 2 Feb 2023 13:00:05 -0800 Subject: [PATCH 09/37] anon namespace --- cpp/src/utilities/logger.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 1459989cb7e..2efaa1a5403 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -23,7 +23,7 @@ #include #include -namespace cudf { +namespace { /** * @brief Returns the default log filename for the global logger. @@ -34,12 +34,16 @@ namespace cudf { * * @return std::string The default log file name. */ -inline std::string default_log_filename() +std::string default_log_filename() { auto* filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; } +} // namespace + +namespace cudf { + /** * @brief Simple wrapper around a spdlog::logger that performs cuDF-specific initialization. */ From 36004e53f119eb679299de6aad8e6157b2bc1c56 Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 3 Feb 2023 12:58:06 -0800 Subject: [PATCH 10/37] tests mostly --- cpp/src/utilities/logger.cpp | 11 +-- cpp/tests/CMakeLists.txt | 1 + cpp/tests/utilities_tests/logger_tests.cpp | 80 ++++++++++++++++++++++ 3 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 cpp/tests/utilities_tests/logger_tests.cpp diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 2efaa1a5403..9336605eb51 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -20,7 +20,6 @@ #include -#include #include namespace { @@ -40,10 +39,6 @@ std::string default_log_filename() return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; } -} // namespace - -namespace cudf { - /** * @brief Simple wrapper around a spdlog::logger that performs cuDF-specific initialization. */ @@ -80,10 +75,10 @@ struct logger_wrapper { } }; -spdlog::logger& logger() +} // namespace + +spdlog::logger& cudf::logger() { static logger_wrapper wrapped{}; return wrapped.logger_; } - -} // namespace cudf diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 053acafdd3d..2392900258c 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -284,6 +284,7 @@ ConfigureTest( utilities_tests/column_utilities_tests.cpp utilities_tests/column_wrapper_tests.cpp utilities_tests/lists_column_wrapper_tests.cpp + utilities_tests/logger_tests.cpp utilities_tests/default_stream_tests.cpp utilities_tests/type_check_tests.cpp ) diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp new file mode 100644 index 00000000000..2df50474814 --- /dev/null +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#include + +struct LoggerTest : public cudf::test::BaseFixture {}; + +namespace { + +std::ostringstream sink_ss() +{ + std::ostringstream oss; + cudf::logger().sinks() = {std::make_shared(oss)}; + cudf::logger().set_formatter( + std::unique_ptr(new spdlog::pattern_formatter("%v"))); + return oss; +} + +} // namespace + +TEST_F(LoggerTest, Basic) +{ + auto ss = sink_ss(); + cudf::logger().critical("crit msg"); + ASSERT_EQ(ss.str(), "crit msg\n"); +} + +TEST_F(LoggerTest, DefaultLevel) +{ + auto ss = sink_ss(); + + cudf::logger().trace("trace"); + cudf::logger().debug("debug"); + cudf::logger().info("info"); + cudf::logger().warn("warn"); + cudf::logger().error("error"); + cudf::logger().critical("critical"); + ASSERT_EQ(ss.str(), "info\nwarn\nerror\ncritical\n"); +} + +TEST_F(LoggerTest, CustomLevel) +{ + auto ss = sink_ss(); + + auto lvl = cudf::logger().level(); + + cudf::logger().set_level(spdlog::level::warn); + cudf::logger().info("info"); + cudf::logger().warn("warn"); + ASSERT_EQ(ss.str(), "warn\n"); + + // clear sink + ss.str(std::string()); + + cudf::logger().set_level(spdlog::level::debug); + cudf::logger().trace("trace"); + cudf::logger().debug("debug"); + ASSERT_EQ(ss.str(), "debug\n"); + + // revert to default level + cudf::logger().set_level(lvl); +} From 0a90a8fbb7017020d0fbb26630df3a46bae1ca33 Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 3 Feb 2023 13:16:44 -0800 Subject: [PATCH 11/37] style --- cpp/tests/utilities_tests/logger_tests.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp index 2df50474814..e17d6289430 100644 --- a/cpp/tests/utilities_tests/logger_tests.cpp +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -21,7 +21,8 @@ #include -struct LoggerTest : public cudf::test::BaseFixture {}; +struct LoggerTest : public cudf::test::BaseFixture { +}; namespace { From 498ac218c69ea6bbd74d27e528b9812babf61874 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 6 Feb 2023 11:55:16 -0800 Subject: [PATCH 12/37] use macro --- cpp/src/io/utilities/config_utils.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/io/utilities/config_utils.hpp b/cpp/src/io/utilities/config_utils.hpp index 85ff99a99a0..681765ff4bd 100644 --- a/cpp/src/io/utilities/config_utils.hpp +++ b/cpp/src/io/utilities/config_utils.hpp @@ -31,9 +31,9 @@ T getenv_or(std::string_view env_var_name, T default_val) { auto const env_val = std::getenv(env_var_name.data()); if (env_val != nullptr) { - logger().debug("Environment variable {} read as {}", env_var_name, env_val); + CUDF_LOG_INFO("Environment variable {} read as {}", env_var_name, env_val); } else { - logger().debug( + CUDF_LOG_INFO( "Environment variable {} is not set, using default value {}", env_var_name, default_val); } From f0ae3e2f2e9fe1fc04a6678da72746ae251e3471 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 6 Feb 2023 16:20:24 -0800 Subject: [PATCH 13/37] fixture --- cpp/tests/utilities_tests/logger_tests.cpp | 55 ++++++++++------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp index e17d6289430..9a4dcb450ec 100644 --- a/cpp/tests/utilities_tests/logger_tests.cpp +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -21,61 +21,56 @@ #include -struct LoggerTest : public cudf::test::BaseFixture { -}; - -namespace { - -std::ostringstream sink_ss() -{ +class LoggerTest : public cudf::test::BaseFixture { std::ostringstream oss; - cudf::logger().sinks() = {std::make_shared(oss)}; - cudf::logger().set_formatter( - std::unique_ptr(new spdlog::pattern_formatter("%v"))); - return oss; -} - -} // namespace + spdlog::level::level_enum prev_level; + std::vector prev_sinks; + + public: + LoggerTest() : prev_level{cudf::logger().level()}, prev_sinks{cudf::logger().sinks()} + { + cudf::logger().sinks() = {std::make_shared(oss)}; + cudf::logger().set_formatter( + std::unique_ptr(new spdlog::pattern_formatter("%v"))); + } + ~LoggerTest() + { + cudf::logger().set_level(prev_level); + cudf::logger().sinks() = prev_sinks; + } + + void clear_sink() { oss.str(""); } + std::string sink_content() { return oss.str(); } +}; TEST_F(LoggerTest, Basic) { - auto ss = sink_ss(); cudf::logger().critical("crit msg"); - ASSERT_EQ(ss.str(), "crit msg\n"); + ASSERT_EQ(this->sink_content(), "crit msg\n"); } TEST_F(LoggerTest, DefaultLevel) { - auto ss = sink_ss(); - cudf::logger().trace("trace"); cudf::logger().debug("debug"); cudf::logger().info("info"); cudf::logger().warn("warn"); cudf::logger().error("error"); cudf::logger().critical("critical"); - ASSERT_EQ(ss.str(), "info\nwarn\nerror\ncritical\n"); + ASSERT_EQ(this->sink_content(), "info\nwarn\nerror\ncritical\n"); } TEST_F(LoggerTest, CustomLevel) { - auto ss = sink_ss(); - - auto lvl = cudf::logger().level(); - cudf::logger().set_level(spdlog::level::warn); cudf::logger().info("info"); cudf::logger().warn("warn"); - ASSERT_EQ(ss.str(), "warn\n"); + ASSERT_EQ(this->sink_content(), "warn\n"); - // clear sink - ss.str(std::string()); + this->clear_sink(); cudf::logger().set_level(spdlog::level::debug); cudf::logger().trace("trace"); cudf::logger().debug("debug"); - ASSERT_EQ(ss.str(), "debug\n"); - - // revert to default level - cudf::logger().set_level(lvl); + ASSERT_EQ(this->sink_content(), "debug\n"); } From 6ab194cd5cdda5d87b7fd8feda6bf4a6f026fb85 Mon Sep 17 00:00:00 2001 From: vuule Date: Wed, 8 Feb 2023 18:34:08 -0800 Subject: [PATCH 14/37] separate public logger API from logging macros --- conda/recipes/libcudf/meta.yaml | 1 + cpp/include/cudf/detail/utilities/logger.hpp | 29 ++++++++++++++++++++ cpp/include/cudf/utilities/logger.hpp | 19 +++++-------- cpp/src/io/utilities/config_utils.hpp | 2 +- cpp/tests/utilities_tests/logger_tests.cpp | 2 +- 5 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 cpp/include/cudf/detail/utilities/logger.hpp diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 2b5cddfe9ec..ca16c1d2434 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -125,6 +125,7 @@ outputs: - test -f $PREFIX/include/cudf/detail/utilities/int_fastdiv.h - test -f $PREFIX/include/cudf/detail/utilities/integer_utils.hpp - test -f $PREFIX/include/cudf/detail/utilities/linked_column.hpp + - test -f $PREFIX/include/cudf/detail/utilities/logger.hpp - test -f $PREFIX/include/cudf/detail/utilities/pinned_allocator.hpp - test -f $PREFIX/include/cudf/detail/utilities/vector_factories.hpp - test -f $PREFIX/include/cudf/detail/utilities/visitor_overload.hpp diff --git a/cpp/include/cudf/detail/utilities/logger.hpp b/cpp/include/cudf/detail/utilities/logger.hpp new file mode 100644 index 00000000000..00fd76adcf9 --- /dev/null +++ b/cpp/include/cudf/detail/utilities/logger.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +// 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 CUDF_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_INFO(...) SPDLOG_LOGGER_INFO(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_WARN(...) SPDLOG_LOGGER_WARN(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&cudf::logger(), __VA_ARGS__) +#define CUDF_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&cudf::logger(), __VA_ARGS__) diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp index 8789b450f91..b2db6115203 100644 --- a/cpp/include/cudf/utilities/logger.hpp +++ b/cpp/include/cudf/utilities/logger.hpp @@ -27,22 +27,17 @@ namespace cudf { /** - * @brief Returns the global logger + * @brief Returns the global logger. * - * This is a spdlog logger. The easiest way to log messages is to use the `CUDF_LOG_*` macros. + * This is a global instance of a spdlog logger. It can be used to configure logging behavior in + * libcudf. + * + * Example: TODO + * + * Note: TODO * * @return spdlog::logger& The logger. */ 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 CUDF_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&cudf::logger(), __VA_ARGS__) -#define CUDF_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&cudf::logger(), __VA_ARGS__) -#define CUDF_LOG_INFO(...) SPDLOG_LOGGER_INFO(&cudf::logger(), __VA_ARGS__) -#define CUDF_LOG_WARN(...) SPDLOG_LOGGER_WARN(&cudf::logger(), __VA_ARGS__) -#define CUDF_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&cudf::logger(), __VA_ARGS__) -#define CUDF_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&cudf::logger(), __VA_ARGS__) - } // namespace cudf diff --git a/cpp/src/io/utilities/config_utils.hpp b/cpp/src/io/utilities/config_utils.hpp index 681765ff4bd..74df1375e6f 100644 --- a/cpp/src/io/utilities/config_utils.hpp +++ b/cpp/src/io/utilities/config_utils.hpp @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp index 9a4dcb450ec..92a0f64ac09 100644 --- a/cpp/tests/utilities_tests/logger_tests.cpp +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include From bc12b13d92f05945b2ae914dc41094a8622b1155 Mon Sep 17 00:00:00 2001 From: vuule Date: Thu, 9 Feb 2023 00:14:37 -0800 Subject: [PATCH 15/37] guide start --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 3c3d5358e43..876fb74a0c3 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -901,6 +901,11 @@ void trivial_types_only(T t){ } ``` +# Logging + +By default, libcudf logs important information into file named `cudf_log.txt` in the current directory. +TBC... + # Data Types Columns may contain data of a number of types (see `enum class type_id` in `include/cudf/types.hpp`) From c736164b383e6d8f9f307f38df543ac2af928a4b Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 10 Feb 2023 15:24:42 -0800 Subject: [PATCH 16/37] header docs --- cpp/include/cudf/utilities/logger.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp index b2db6115203..1291902426e 100644 --- a/cpp/include/cudf/utilities/logger.hpp +++ b/cpp/include/cudf/utilities/logger.hpp @@ -32,9 +32,18 @@ namespace cudf { * This is a global instance of a spdlog logger. It can be used to configure logging behavior in * libcudf. * - * Example: TODO + * Examples: + * @code{.cpp} + * // Turn off logging at runtime + * cudf::logger().set_level(spdlog::level::off); + * // Add a stdout sink to the logger + * cudf::logger().sinks().push_back(std::make_shared()); + * // Replace the default sink + * cudf::logger().sinks() ={std::make_shared()}; + * @endcode * - * Note: TODO + * Note: Changes to the sinks are not thread safe and should only be done during global + * initialization. * * @return spdlog::logger& The logger. */ From df803a4a667f7d91f3541ec38f66d6478eed4e0a Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 13 Feb 2023 16:24:57 -0800 Subject: [PATCH 17/37] dev guide --- .../developer_guide/DEVELOPER_GUIDE.md | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 876fb74a0c3..31fa8a501e9 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -903,8 +903,38 @@ void trivial_types_only(T t){ # Logging -By default, libcudf logs important information into file named `cudf_log.txt` in the current directory. -TBC... +libcudf includes logging utilities (built on top of [spdlog](#https://github.com/gabime/spdlog.git) +library), which should be used to log important events (e.g. warnings). This utility can also be +used to log debug information, as long as correct logging level is used. libcudf contains six macros +that should be used for logging at different levels: + +* `CUDF_LOG_TRACE` - verbose debug messages (only relevant for developers); +* `CUDF_LOG_DEBUG` - debug messages (only relevant for developers); +* `CUDF_LOG_INFO` - information about rare events that occur during normal execution; +* `CUDF_LOG_WARN` - warnings about potentially unexpected behavior, deprecations; +* `CUDF_LOG_ERROR` - recoverable errors +* `CUDF_LOG_CRITICAL` - unrecoverable errors (e.g. memory corruption) + +By default, messages below the info level are excluded from the log. In public builds, the code that +logs at these levels is compiled out. This prevents logging of potentially sensitive data that might +be done for debug purposes. Also, this allows developers to include expensive computation in the +trace/debug logs, as the overhead will not be present in the public builds. The minimum enabled +logging level is info, but it can be modified in multiple ways: + +* CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that +will be compiled in the build. +Available levels are TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL and OFF. +* Environment variable `LIBCUDF_LOGGING_LEVEL`, with the same values as the CMake variable. +The difference is that disabled levels are present in the build, but the messages are excluded from +the log. +* Global logger object exposed via `cudf::logger()`. This API should not be used within libcudf to +manipulate logging, +it's purpose is to allow upstream users to configure libcudf logging to fit their application. + +The default log file is `cudf_log.txt` in the current working directory. +The environment variable `LIBCUDF_DEBUG_LOG_FILE` can be set to specify the path and file name. +Upstream users can also manipulate `cudf::logger().sinks()` to add sinks or divert the log to standard +output or even a custom spdlog sink. # Data Types From d6b814502cccec4397e6f830b475093e061198b5 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 13 Feb 2023 16:36:29 -0800 Subject: [PATCH 18/37] clean up --- .../developer_guide/DEVELOPER_GUIDE.md | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 31fa8a501e9..127dee9fea2 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -903,27 +903,28 @@ void trivial_types_only(T t){ # Logging -libcudf includes logging utilities (built on top of [spdlog](#https://github.com/gabime/spdlog.git) -library), which should be used to log important events (e.g. warnings). This utility can also be -used to log debug information, as long as correct logging level is used. libcudf contains six macros +libcudf includes logging utilities (built on top of [spdlog](https://github.com/gabime/spdlog) +library), which should be used to log important events (e.g. user warnings). This utility can also +be used to log debug information, as long as the correct logging level is used. There are six macros that should be used for logging at different levels: -* `CUDF_LOG_TRACE` - verbose debug messages (only relevant for developers); -* `CUDF_LOG_DEBUG` - debug messages (only relevant for developers); -* `CUDF_LOG_INFO` - information about rare events that occur during normal execution; -* `CUDF_LOG_WARN` - warnings about potentially unexpected behavior, deprecations; +* `CUDF_LOG_TRACE` - verbose debug messages (targeted at developers); +* `CUDF_LOG_DEBUG` - debug messages (targeted at developers); +* `CUDF_LOG_INFO` - information about rare events (e.g. once per run) that occur during normal +execution; +* `CUDF_LOG_WARN` - user warnings about potentially unexpected behavior, deprecations; * `CUDF_LOG_ERROR` - recoverable errors * `CUDF_LOG_CRITICAL` - unrecoverable errors (e.g. memory corruption) -By default, messages below the info level are excluded from the log. In public builds, the code that -logs at these levels is compiled out. This prevents logging of potentially sensitive data that might -be done for debug purposes. Also, this allows developers to include expensive computation in the -trace/debug logs, as the overhead will not be present in the public builds. The minimum enabled -logging level is info, but it can be modified in multiple ways: +By default, messages below the `INFO` level are excluded from the log. In public builds, the code +that logs at these levels is compiled out. This prevents logging of potentially sensitive data that +might be done for debug purposes. Also, this allows developers to include expensive computation in +the trace/debug logs, as the overhead will not be present in the public builds. The minimum enabled +logging level is `INFO`, and it can be modified in multiple ways: * CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that will be compiled in the build. -Available levels are TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL and OFF. +Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL` and `OFF`. * Environment variable `LIBCUDF_LOGGING_LEVEL`, with the same values as the CMake variable. The difference is that disabled levels are present in the build, but the messages are excluded from the log. From e813cb9c3fd45ee280791b58af26b575f83e32d2 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 13 Feb 2023 16:41:34 -0800 Subject: [PATCH 19/37] build changes --- cpp/CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3349e00ce09..a40e814b335 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -120,15 +120,15 @@ set(CUDF_CUDA_FLAGS "") set(CUDF_CXX_DEFINITIONS "") set(CUDF_CUDA_DEFINITIONS "") -# Set RMM logging level -set(RMM_LOGGING_LEVEL +# Set logging level +set(LIBCUDF_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level." ) set_property( - CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF" + CACHE LIBCUDF_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF" ) -message(VERBOSE "CUDF: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.") +message(VERBOSE "CUDF: LIBCUDF_LOGGING_LEVEL = '${LIBCUDF_LOGGING_LEVEL}'.") if(NOT CUDF_GENERATED_INCLUDE_DIR) set(CUDF_GENERATED_INCLUDE_DIR ${CUDF_BINARY_DIR}) @@ -677,8 +677,11 @@ if(NOT USE_NVTX) target_compile_definitions(cudf PUBLIC NVTX_DISABLE) endif() +# Define RMM logging level +target_compile_definitions(cudf PUBLIC "RMM_LOGGING_LEVEL=LIBCUDF_LOGGING_LEVEL") + # Define spdlog level -target_compile_definitions(cudf PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") +target_compile_definitions(cudf PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${LIBCUDF_LOGGING_LEVEL}") # Compile stringified JIT sources first add_dependencies(cudf jitify_preprocess_run) From b1f099467d8af5522b474d52547bef77f00f042f Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 13 Feb 2023 23:03:44 -0800 Subject: [PATCH 20/37] style --- cpp/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a40e814b335..6fce14ec3bb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -126,7 +126,8 @@ set(LIBCUDF_LOGGING_LEVEL CACHE STRING "Choose the logging level." ) set_property( - CACHE LIBCUDF_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF" + CACHE LIBCUDF_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" + "OFF" ) message(VERBOSE "CUDF: LIBCUDF_LOGGING_LEVEL = '${LIBCUDF_LOGGING_LEVEL}'.") From 30fcd287323ec9fa58822d4e151f956a881ea33b Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Wed, 15 Feb 2023 14:49:47 -0800 Subject: [PATCH 21/37] Apply suggestions from code review Co-authored-by: Bradley Dice --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 12 ++++++------ cpp/src/utilities/logger.cpp | 3 +-- cpp/tests/utilities_tests/logger_tests.cpp | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 127dee9fea2..34bc9de3638 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -908,11 +908,11 @@ library), which should be used to log important events (e.g. user warnings). Thi be used to log debug information, as long as the correct logging level is used. There are six macros that should be used for logging at different levels: -* `CUDF_LOG_TRACE` - verbose debug messages (targeted at developers); -* `CUDF_LOG_DEBUG` - debug messages (targeted at developers); +* `CUDF_LOG_TRACE` - verbose debug messages (targeted at developers) +* `CUDF_LOG_DEBUG` - debug messages (targeted at developers) * `CUDF_LOG_INFO` - information about rare events (e.g. once per run) that occur during normal -execution; -* `CUDF_LOG_WARN` - user warnings about potentially unexpected behavior, deprecations; +execution +* `CUDF_LOG_WARN` - user warnings about potentially unexpected behavior or deprecations * `CUDF_LOG_ERROR` - recoverable errors * `CUDF_LOG_CRITICAL` - unrecoverable errors (e.g. memory corruption) @@ -924,13 +924,13 @@ logging level is `INFO`, and it can be modified in multiple ways: * CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that will be compiled in the build. -Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL` and `OFF`. +Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, and `OFF`. * Environment variable `LIBCUDF_LOGGING_LEVEL`, with the same values as the CMake variable. The difference is that disabled levels are present in the build, but the messages are excluded from the log. * Global logger object exposed via `cudf::logger()`. This API should not be used within libcudf to manipulate logging, -it's purpose is to allow upstream users to configure libcudf logging to fit their application. +its purpose is to allow upstream users to configure libcudf logging to fit their application. The default log file is `cudf_log.txt` in the current working directory. The environment variable `LIBCUDF_DEBUG_LOG_FILE` can be set to specify the path and file name. diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 9336605eb51..959e038bf01 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -14,9 +14,8 @@ * limitations under the License. */ -#include - #include +#include #include diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp index 92a0f64ac09..9cb55272b5f 100644 --- a/cpp/tests/utilities_tests/logger_tests.cpp +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -14,9 +14,10 @@ * limitations under the License. */ -#include #include +#include + #include #include From 588d6f5faaf9b1eeddd3941e52772a0ee26b631c Mon Sep 17 00:00:00 2001 From: vuule Date: Wed, 15 Feb 2023 15:25:10 -0800 Subject: [PATCH 22/37] remove GCC workaround --- cpp/include/cudf/utilities/logger.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cpp/include/cudf/utilities/logger.hpp b/cpp/include/cudf/utilities/logger.hpp index 1291902426e..a39df064f44 100644 --- a/cpp/include/cudf/utilities/logger.hpp +++ b/cpp/include/cudf/utilities/logger.hpp @@ -16,12 +16,6 @@ #pragma once -// If using GCC, temporary workaround for older libcudacxx defining _LIBCPP_VERSION -// undefine it before including spdlog, due to fmtlib checking if it is defined -// TODO: remove once libcudacxx is on Github and RAPIDS depends on it -#ifdef __GNUG__ -#undef _LIBCPP_VERSION -#endif #include namespace cudf { From 0c247178edb3eb2a2dd615f0cac08884f316086c Mon Sep 17 00:00:00 2001 From: vuule Date: Wed, 15 Feb 2023 15:25:19 -0800 Subject: [PATCH 23/37] fix string constant --- cpp/src/utilities/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 959e038bf01..72d67b3d7a0 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -53,7 +53,7 @@ struct logger_wrapper { if (str == "DEBUG") return spdlog::level::debug; if (str == "INFO") return spdlog::level::info; if (str == "WARN") return spdlog::level::warn; - if (str == "ERR") return spdlog::level::err; + if (str == "ERROR") return spdlog::level::err; if (str == "CRITICAL") return spdlog::level::critical; if (str == "OFF") return spdlog::level::off; From 6fea0bfd4233ed78718a0c132a608515f3790e5e Mon Sep 17 00:00:00 2001 From: vuule Date: Fri, 17 Feb 2023 17:15:22 -0800 Subject: [PATCH 24/37] update default level, sink --- cpp/src/utilities/logger.cpp | 64 ++++++++++------------ cpp/tests/utilities_tests/logger_tests.cpp | 2 +- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 72d67b3d7a0..1c533c60e2c 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -17,6 +17,7 @@ #include #include +#include "spdlog/sinks/stdout_sinks.h" #include #include @@ -24,18 +25,35 @@ namespace { /** - * @brief Returns the default log filename for the global logger. - * - * If the environment variable `CUDF_DEBUG_LOG_FILE` is defined, its value is used as the path and - * name of the log file. Otherwise, the file `cudf_log.txt` in the current working directory is - * used. - * - * @return std::string The default log file name. + * @brief TODO */ -std::string default_log_filename() +[[nodiscard]] spdlog::sink_ptr make_libcudf_sink() { - auto* filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); - return (filename == nullptr) ? std::string{"cudf_log.txt"} : std::string{filename}; + if (auto filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); filename != nullptr) { + return std::make_shared(filename, true); + } else { + return std::make_shared(); + } +} + +/** + * @brief Converts the level name into the `spdlog` level enum. + */ +[[nodiscard]] spdlog::level::level_enum libcudf_log_level() +{ + auto const env_level = std::getenv("LIBCUDF_LOGGING_LEVEL"); + if (env_level == nullptr) { return spdlog::level::warn; } + + auto const env_lvl_str = std::string(env_level); + if (env_lvl_str == "TRACE") return spdlog::level::trace; + if (env_lvl_str == "DEBUG") return spdlog::level::debug; + if (env_lvl_str == "INFO") return spdlog::level::info; + if (env_lvl_str == "WARN") return spdlog::level::warn; + if (env_lvl_str == "ERROR") return spdlog::level::err; + if (env_lvl_str == "CRITICAL") return spdlog::level::critical; + if (env_lvl_str == "OFF") return spdlog::level::off; + + CUDF_FAIL("Invalid value for LIBCUDF_LOGGING_LEVEL environment variable"); } /** @@ -44,33 +62,11 @@ std::string default_log_filename() struct logger_wrapper { spdlog::logger logger_; - /** - * @brief Converts the level name into the `spdlog` level enum. - */ - spdlog::level::level_enum spdlog_level_from_string(std::string_view str) - { - if (str == "TRACE") return spdlog::level::trace; - if (str == "DEBUG") return spdlog::level::debug; - if (str == "INFO") return spdlog::level::info; - if (str == "WARN") return spdlog::level::warn; - if (str == "ERROR") return spdlog::level::err; - if (str == "CRITICAL") return spdlog::level::critical; - if (str == "OFF") return spdlog::level::off; - - CUDF_FAIL("Invalid value for LIBCUDF_LOGGING_LEVEL environment variable"); - } - - logger_wrapper() - : logger_{"CUDF", - std::make_shared( - default_log_filename(), true // truncate file - )} + logger_wrapper() : logger_{"CUDF", make_libcudf_sink()} { logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); + logger_.set_level(libcudf_log_level()); logger_.flush_on(spdlog::level::warn); - - auto const env_level = std::getenv("LIBCUDF_LOGGING_LEVEL"); - if (env_level != nullptr) { logger_.set_level(spdlog_level_from_string(env_level)); } } }; diff --git a/cpp/tests/utilities_tests/logger_tests.cpp b/cpp/tests/utilities_tests/logger_tests.cpp index 9cb55272b5f..9d44e9d8247 100644 --- a/cpp/tests/utilities_tests/logger_tests.cpp +++ b/cpp/tests/utilities_tests/logger_tests.cpp @@ -58,7 +58,7 @@ TEST_F(LoggerTest, DefaultLevel) cudf::logger().warn("warn"); cudf::logger().error("error"); cudf::logger().critical("critical"); - ASSERT_EQ(this->sink_content(), "info\nwarn\nerror\ncritical\n"); + ASSERT_EQ(this->sink_content(), "warn\nerror\ncritical\n"); } TEST_F(LoggerTest, CustomLevel) From 5581c8a9f9a159a11dc8ee79fd76701bf7ec031b Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 15:29:36 -0800 Subject: [PATCH 25/37] switch to stderr --- cpp/src/utilities/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 1c533c60e2c..127c3652648 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -32,7 +32,7 @@ namespace { if (auto filename = std::getenv("LIBCUDF_DEBUG_LOG_FILE"); filename != nullptr) { return std::make_shared(filename, true); } else { - return std::make_shared(); + return std::make_shared(); } } From 6378bf7be264c2a1e15217d959c590498fde1477 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 15:48:14 -0800 Subject: [PATCH 26/37] missing doc --- cpp/src/utilities/logger.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 127c3652648..60e3c9834e6 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -25,7 +25,9 @@ namespace { /** - * @brief TODO + * @brief Creates a sink for libcudf logging. + * + * Returns a file sink if the file name has been specified, otherwise returns a stderr sink. */ [[nodiscard]] spdlog::sink_ptr make_libcudf_sink() { From 553a57bc485ada6baae554a052cfec01e050403d Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 15:55:10 -0800 Subject: [PATCH 27/37] docs improvement --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 34bc9de3638..4748e54f6b8 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -916,7 +916,7 @@ execution * `CUDF_LOG_ERROR` - recoverable errors * `CUDF_LOG_CRITICAL` - unrecoverable errors (e.g. memory corruption) -By default, messages below the `INFO` level are excluded from the log. In public builds, the code +By default, `TRACE` and `DEBUG` messages are excluded from the log. In public builds, the code that logs at these levels is compiled out. This prevents logging of potentially sensitive data that might be done for debug purposes. Also, this allows developers to include expensive computation in the trace/debug logs, as the overhead will not be present in the public builds. The minimum enabled From 49f3896eb6f08164ceb78ea459ba96aa49ca032a Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 15:57:55 -0800 Subject: [PATCH 28/37] remove outdated docs --- cpp/include/cudf/detail/utilities/logger.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/cpp/include/cudf/detail/utilities/logger.hpp b/cpp/include/cudf/detail/utilities/logger.hpp index 00fd76adcf9..8c1c3c28df8 100644 --- a/cpp/include/cudf/detail/utilities/logger.hpp +++ b/cpp/include/cudf/detail/utilities/logger.hpp @@ -18,8 +18,6 @@ #include -// 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 CUDF_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&cudf::logger(), __VA_ARGS__) #define CUDF_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&cudf::logger(), __VA_ARGS__) From 0b6b27cf45601258a587287d68e9fc630d4f957d Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 16:32:33 -0800 Subject: [PATCH 29/37] update dev guide --- .../developer_guide/DEVELOPER_GUIDE.md | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 4748e54f6b8..dcc2056fcf3 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -916,11 +916,12 @@ execution * `CUDF_LOG_ERROR` - recoverable errors * `CUDF_LOG_CRITICAL` - unrecoverable errors (e.g. memory corruption) -By default, `TRACE` and `DEBUG` messages are excluded from the log. In public builds, the code -that logs at these levels is compiled out. This prevents logging of potentially sensitive data that -might be done for debug purposes. Also, this allows developers to include expensive computation in -the trace/debug logs, as the overhead will not be present in the public builds. The minimum enabled -logging level is `INFO`, and it can be modified in multiple ways: +By default, `TRACE`, `DEBUG` and `INFO` messages are excluded from the log. In addition, in public +builds, the code that logs at `TRACE` and `DEBUG` levels is compiled out. This prevents logging of +potentially sensitive data that might be done for debug purposes. Also, this allows developers to +include expensive computation in the trace/debug logs, as the overhead will not be present in the + public builds. + The minimum enabled logging level is `WARN`, and it can be modified in multiple ways: * CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that will be compiled in the build. @@ -932,10 +933,11 @@ the log. manipulate logging, its purpose is to allow upstream users to configure libcudf logging to fit their application. -The default log file is `cudf_log.txt` in the current working directory. -The environment variable `LIBCUDF_DEBUG_LOG_FILE` can be set to specify the path and file name. -Upstream users can also manipulate `cudf::logger().sinks()` to add sinks or divert the log to standard -output or even a custom spdlog sink. +By default, logging messages are output to stderr. +Setting the environment variable `LIBCUDF_DEBUG_LOG_FILE` redirects the log to a file with the +specified path (can be relative to the current directory). +Upstream users can also manipulate `cudf::logger().sinks()` to add sinks or divert the log to +standard output or even a custom spdlog sink. # Data Types From a54092823fccbb8fe1439c68928c1ec466d79514 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 27 Feb 2023 16:34:08 -0800 Subject: [PATCH 30/37] small fixes --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index dcc2056fcf3..a4b495277b2 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -919,9 +919,9 @@ execution By default, `TRACE`, `DEBUG` and `INFO` messages are excluded from the log. In addition, in public builds, the code that logs at `TRACE` and `DEBUG` levels is compiled out. This prevents logging of potentially sensitive data that might be done for debug purposes. Also, this allows developers to -include expensive computation in the trace/debug logs, as the overhead will not be present in the - public builds. - The minimum enabled logging level is `WARN`, and it can be modified in multiple ways: +include expensive computation in the trace/debug logs, as the overhead will not be present in the +public builds. +The minimum enabled logging level is `WARN`, and it can be modified in multiple ways: * CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that will be compiled in the build. @@ -930,8 +930,8 @@ Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, and The difference is that disabled levels are present in the build, but the messages are excluded from the log. * Global logger object exposed via `cudf::logger()`. This API should not be used within libcudf to -manipulate logging, -its purpose is to allow upstream users to configure libcudf logging to fit their application. +manipulate logging, its purpose is to allow upstream users to configure libcudf logging to fit their +application. By default, logging messages are output to stderr. Setting the environment variable `LIBCUDF_DEBUG_LOG_FILE` redirects the log to a file with the From dcd3b2975da07588e398e8b53416074fe780596e Mon Sep 17 00:00:00 2001 From: vuule Date: Tue, 28 Feb 2023 10:10:30 -0800 Subject: [PATCH 31/37] style --- cpp/src/utilities/logger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/utilities/logger.cpp b/cpp/src/utilities/logger.cpp index 60e3c9834e6..91950850e3b 100644 --- a/cpp/src/utilities/logger.cpp +++ b/cpp/src/utilities/logger.cpp @@ -25,8 +25,8 @@ namespace { /** - * @brief Creates a sink for libcudf logging. - * + * @brief Creates a sink for libcudf logging. + * * Returns a file sink if the file name has been specified, otherwise returns a stderr sink. */ [[nodiscard]] spdlog::sink_ptr make_libcudf_sink() From c75ff339ab83775687dcdb32a5f318a13db4748b Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 6 Mar 2023 12:22:19 -0800 Subject: [PATCH 32/37] cmake changes --- cpp/CMakeLists.txt | 4 ++++ cpp/cmake/thirdparty/get_fmt.cmake | 22 ++++++++++++++++++ cpp/cmake/thirdparty/get_spdlog.cmake | 33 +++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 cpp/cmake/thirdparty/get_fmt.cmake create mode 100644 cpp/cmake/thirdparty/get_spdlog.cmake diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 8917be349e7..3125a4afbb0 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -192,6 +192,10 @@ include(cmake/Modules/JitifyPreprocessKernels.cmake) include(cmake/thirdparty/get_cufile.cmake) # find KvikIO include(cmake/thirdparty/get_kvikio.cmake) +# find fmt +include(cmake/thirdparty/get_fmt.cmake) +# find spdlog +include(cmake/thirdparty/get_spdlog.cmake) # Workaround until https://github.com/rapidsai/rapids-cmake/issues/176 is resolved if(NOT BUILD_SHARED_LIBS) diff --git a/cpp/cmake/thirdparty/get_fmt.cmake b/cpp/cmake/thirdparty/get_fmt.cmake new file mode 100644 index 00000000000..3be9267c435 --- /dev/null +++ b/cpp/cmake/thirdparty/get_fmt.cmake @@ -0,0 +1,22 @@ +# ============================================================================= +# Copyright (c) 2023, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +# Use CPM to find or clone fmt +function(find_and_configure_fmt) + + include(${rapids-cmake-dir}/cpm/fmt.cmake) + rapids_cpm_fmt(INSTALL_EXPORT_SET cudf-exports BUILD_EXPORT_SET cudf-exports) +endfunction() + +find_and_configure_fmt() \ No newline at end of file diff --git a/cpp/cmake/thirdparty/get_spdlog.cmake b/cpp/cmake/thirdparty/get_spdlog.cmake new file mode 100644 index 00000000000..084a30d8508 --- /dev/null +++ b/cpp/cmake/thirdparty/get_spdlog.cmake @@ -0,0 +1,33 @@ +# ============================================================================= +# Copyright (c) 2023, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +# Use CPM to find or clone speedlog +function(find_and_configure_spdlog) + + include(${rapids-cmake-dir}/cpm/spdlog.cmake) + rapids_cpm_spdlog(FMT_OPTION "EXTERNAL_FMT_HO" INSTALL_EXPORT_SET cudf-exports) + rapids_export_package(BUILD spdlog cudf-exports) + + if(spdlog_ADDED) + rapids_export( + BUILD spdlog + EXPORT_SET spdlog + GLOBAL_TARGETS spdlog spdlog_header_only + NAMESPACE spdlog::) + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] cudf-exports) + endif() +endfunction() + +find_and_configure_spdlog() \ No newline at end of file From a8c3e11f3c6b2a902ad002f9ad20e798c3170096 Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 6 Mar 2023 12:22:26 -0800 Subject: [PATCH 33/37] conda changes --- conda/recipes/libcudf/conda_build_config.yaml | 6 ++++++ conda/recipes/libcudf/meta.yaml | 2 ++ dependencies.yaml | 2 ++ 3 files changed, 10 insertions(+) diff --git a/conda/recipes/libcudf/conda_build_config.yaml b/conda/recipes/libcudf/conda_build_config.yaml index ff8d9026aef..ac84737192d 100644 --- a/conda/recipes/libcudf/conda_build_config.yaml +++ b/conda/recipes/libcudf/conda_build_config.yaml @@ -24,3 +24,9 @@ dlpack_version: librdkafka_version: - ">=1.7.0,<1.8.0a0" + +fmt_version: + - ">=9.1.0,<10" + +spdlog_version: + - ">=1.11.0,<1.12" diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 43c45037aff..7a6a7c1981e 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -47,6 +47,8 @@ requirements: - libarrow {{ libarrow_version }} - dlpack {{ dlpack_version }} - librdkafka {{ librdkafka_version }} + - fmt {{ fmt_version }} + - spdlog {{ spdlog_version }} outputs: - name: libcudf diff --git a/dependencies.yaml b/dependencies.yaml index 2c359d58378..c9ed45233df 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -103,7 +103,9 @@ dependencies: - librmm=23.04.* - output_types: conda packages: + - fmt>=9.1.0,<10 - librdkafka=1.7.0 + - spdlog>=1.11.0,<1.12 build_python: common: - output_types: [conda, requirements] From eb045f74ab041418603214d98ac8f355db7b5b6e Mon Sep 17 00:00:00 2001 From: vuule Date: Mon, 6 Mar 2023 12:28:25 -0800 Subject: [PATCH 34/37] style --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 ++ cpp/cmake/thirdparty/get_fmt.cmake | 2 +- cpp/cmake/thirdparty/get_spdlog.cmake | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 00aa1e2bc0f..c69ef51bb03 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -27,6 +27,7 @@ dependencies: - dlpack>=0.5,<0.6.0a0 - doxygen=1.8.20 - fastavro>=0.22.9 +- fmt>=9.1.0,<10 - fsspec>=0.6.0 - gcc_linux-64=9.* - hypothesis @@ -68,6 +69,7 @@ dependencies: - s3fs>=2022.3.0 - scikit-build>=0.13.1 - scipy +- spdlog>=1.11.0,<1.12 - sphinx - sphinx-autobuild - sphinx-copybutton diff --git a/cpp/cmake/thirdparty/get_fmt.cmake b/cpp/cmake/thirdparty/get_fmt.cmake index 3be9267c435..083dd1d0631 100644 --- a/cpp/cmake/thirdparty/get_fmt.cmake +++ b/cpp/cmake/thirdparty/get_fmt.cmake @@ -19,4 +19,4 @@ function(find_and_configure_fmt) rapids_cpm_fmt(INSTALL_EXPORT_SET cudf-exports BUILD_EXPORT_SET cudf-exports) endfunction() -find_and_configure_fmt() \ No newline at end of file +find_and_configure_fmt() diff --git a/cpp/cmake/thirdparty/get_spdlog.cmake b/cpp/cmake/thirdparty/get_spdlog.cmake index 084a30d8508..fff5b84af0d 100644 --- a/cpp/cmake/thirdparty/get_spdlog.cmake +++ b/cpp/cmake/thirdparty/get_spdlog.cmake @@ -24,10 +24,11 @@ function(find_and_configure_spdlog) BUILD spdlog EXPORT_SET spdlog GLOBAL_TARGETS spdlog spdlog_header_only - NAMESPACE spdlog::) + NAMESPACE spdlog:: + ) include("${rapids-cmake-dir}/export/find_package_root.cmake") rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] cudf-exports) endif() endfunction() -find_and_configure_spdlog() \ No newline at end of file +find_and_configure_spdlog() From 2280ecf85a6ca3e2b026ddbdaab429f105bfb88e Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Thu, 9 Mar 2023 16:29:24 -0800 Subject: [PATCH 35/37] doc improvement Co-authored-by: Vyas Ramasubramani --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index a4b495277b2..c9abb7147b3 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -926,9 +926,7 @@ The minimum enabled logging level is `WARN`, and it can be modified in multiple * CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that will be compiled in the build. Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, and `OFF`. -* Environment variable `LIBCUDF_LOGGING_LEVEL`, with the same values as the CMake variable. -The difference is that disabled levels are present in the build, but the messages are excluded from -the log. +* Environment variable `LIBCUDF_LOGGING_LEVEL` - controls the runtime logging level. If this setting is higher than the compile-time CMake variable, any logging levels in between the two settings will be excluded from the written log. The available levels are the same as for the CMake variable. * Global logger object exposed via `cudf::logger()`. This API should not be used within libcudf to manipulate logging, its purpose is to allow upstream users to configure libcudf logging to fit their application. From e7fe0cdb2c9eb8aa450a3dda0d5b011b8dd490b9 Mon Sep 17 00:00:00 2001 From: vuule Date: Thu, 9 Mar 2023 17:03:55 -0800 Subject: [PATCH 36/37] docs that killed timezone refactor --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index c9abb7147b3..8cd4f8c6d27 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -923,13 +923,17 @@ include expensive computation in the trace/debug logs, as the overhead will not public builds. The minimum enabled logging level is `WARN`, and it can be modified in multiple ways: -* CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - controls the minimum level of logging that +* CMake configuration variable `LIBCUDF_LOGGING_LEVEL` - sets the minimum level of logging that will be compiled in the build. Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, and `OFF`. -* Environment variable `LIBCUDF_LOGGING_LEVEL` - controls the runtime logging level. If this setting is higher than the compile-time CMake variable, any logging levels in between the two settings will be excluded from the written log. The available levels are the same as for the CMake variable. -* Global logger object exposed via `cudf::logger()`. This API should not be used within libcudf to -manipulate logging, its purpose is to allow upstream users to configure libcudf logging to fit their -application. +* Environment variable `LIBCUDF_LOGGING_LEVEL` - sets the minimum logging level during +initialization. If this setting is higher than the compile-time CMake variable, any logging levels +in between the two settings will be excluded from the written log. The available levels are the same +as for the CMake variable. +* Global logger object exposed via `cudf::logger()` - sets the minimum logging level at runtime. +For example, calling `cudf::logger().set_level(spdlog::level::err)`, will exclude any messages that +are not errors or critical errors. This API should not be used within libcudf to manipulate logging, +its purpose is to allow upstream users to configure libcudf logging to fit their application. By default, logging messages are output to stderr. Setting the environment variable `LIBCUDF_DEBUG_LOG_FILE` redirects the log to a file with the From 1d1950c66b3af9fb6f839e51c5ba4c31286f5378 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Fri, 10 Mar 2023 12:31:25 -0800 Subject: [PATCH 37/37] Update cpp/CMakeLists.txt Co-authored-by: Vyas Ramasubramani --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3125a4afbb0..a261049d3f0 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -684,7 +684,7 @@ if(NOT USE_NVTX) endif() # Define RMM logging level -target_compile_definitions(cudf PUBLIC "RMM_LOGGING_LEVEL=LIBCUDF_LOGGING_LEVEL") +target_compile_definitions(cudf PRIVATE "RMM_LOGGING_LEVEL=LIBCUDF_LOGGING_LEVEL") # Define spdlog level target_compile_definitions(cudf PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${LIBCUDF_LOGGING_LEVEL}")