Skip to content

Commit

Permalink
Fix formatting in logging (#17680)
Browse files Browse the repository at this point in the history
Replace fmt-style `{}` syntax with `printf`-style `%xyz` format strings, because the fmt-style does not work with recent logger changes.

Authors:
  - Vukasin Milovanovic (https://github.com/vuule)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - Yunsong Wang (https://github.com/PointKernel)

URL: #17680
  • Loading branch information
vuule authored Jan 6, 2025
1 parent c4f2e8e commit 5d7686f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
10 changes: 5 additions & 5 deletions cpp/src/io/comp/nvcomp_adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
* Copyright (c) 2022-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -416,11 +416,11 @@ std::optional<std::string> is_compression_disabled(compression_type compression,
memo_map_lock.unlock();

if (reason.has_value()) {
CUDF_LOG_INFO("nvCOMP is disabled for {} compression; reason: {}",
CUDF_LOG_INFO("nvCOMP is disabled for %s compression; reason: %s",
compression_type_name(compression),
reason.value());
} else {
CUDF_LOG_INFO("nvCOMP is enabled for {} compression", compression_type_name(compression));
CUDF_LOG_INFO("nvCOMP is enabled for %s compression", compression_type_name(compression));
}

return reason;
Expand All @@ -445,11 +445,11 @@ std::optional<std::string> is_decompression_disabled(compression_type compressio
memo_map_lock.unlock();

if (reason.has_value()) {
CUDF_LOG_INFO("nvCOMP is disabled for {} decompression; reason: {}",
CUDF_LOG_INFO("nvCOMP is disabled for %s decompression; reason: %s",
compression_type_name(compression),
reason.value());
} else {
CUDF_LOG_INFO("nvCOMP is enabled for {} decompression", compression_type_name(compression));
CUDF_LOG_INFO("nvCOMP is enabled for %s decompression", compression_type_name(compression));
}

return reason;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/csv/reader_impl.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
* Copyright (c) 2019-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -771,7 +771,7 @@ table_with_metadata read_csv(cudf::io::datasource* source,
if (!reader_opts.is_enabled_mangle_dupe_cols()) {
for (auto& col_name : column_names) {
if (++col_names_counts[col_name] > 1) {
CUDF_LOG_WARN("Multiple columns with name {}; only the first appearance is parsed",
CUDF_LOG_WARN("Multiple columns with name %s; only the first appearance is parsed",
col_name);

auto const idx = &col_name - column_names.data();
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/parquet/writer_impl.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
* Copyright (c) 2019-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -719,7 +719,7 @@ std::vector<schema_tree_node> construct_parquet_schema_tree(
// all others
default:
CUDF_LOG_WARN(
"Unsupported page encoding requested: {}; the requested encoding will be ignored",
"Unsupported page encoding requested: %d; the requested encoding will be ignored",
static_cast<int>(col_meta.get_encoding()));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/utilities/data_sink.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,7 +44,7 @@ class file_sink : public data_sink {
if (cufile_integration::is_kvikio_enabled()) {
cufile_integration::set_up_kvikio();
_kvikio_file = kvikio::FileHandle(filepath, "w");
CUDF_LOG_INFO("Writing a file using kvikIO, with compatibility mode {}.",
CUDF_LOG_INFO("Writing a file using kvikIO, with compatibility mode %s.",
_kvikio_file.is_compat_mode_preferred() ? "on" : "off");
} else {
_cufile_out = detail::make_cufile_output(filepath);
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/io/utilities/datasource.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
* Copyright (c) 2019-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,7 +55,7 @@ class file_source : public datasource {
if (cufile_integration::is_kvikio_enabled()) {
cufile_integration::set_up_kvikio();
_kvikio_file = kvikio::FileHandle(filepath);
CUDF_LOG_INFO("Reading a file using kvikIO, with compatibility mode {}.",
CUDF_LOG_INFO("Reading a file using kvikIO, with compatibility mode %s.",
_kvikio_file.is_compat_mode_preferred() ? "on" : "off");
} else {
_cufile_in = detail::make_cufile_input(filepath);
Expand Down Expand Up @@ -230,7 +230,7 @@ class memory_mapped_source : public file_source {
{
if (_map_addr != nullptr) {
auto const result = munmap(_map_addr, _map_size);
if (result != 0) { CUDF_LOG_WARN("munmap failed with {}", result); }
if (result != 0) { CUDF_LOG_WARN("munmap failed with %d", result); }
_map_addr = nullptr;
}
}
Expand Down
15 changes: 11 additions & 4 deletions cpp/src/io/utilities/getenv_or.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION.
* Copyright (c) 2024-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,17 @@ 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) {
CUDF_LOG_INFO("Environment variable {} read as {}", env_var_name, env_val);
CUDF_LOG_INFO("Environment variable %.*s read as %s",
static_cast<int>(env_var_name.length()),
env_var_name.data(),
env_val);
} else {
CUDF_LOG_INFO(
"Environment variable {} is not set, using default value {}", env_var_name, default_val);
std::stringstream ss;
ss << default_val;
CUDF_LOG_INFO("Environment variable %.*s is not set, using default value %s",
static_cast<int>(env_var_name.length()),
env_var_name.data(),
ss.str());
}

if (env_val == nullptr) { return default_val; }
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/utilities/host_memory.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION.
* Copyright (c) 2024-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +46,7 @@ class fixed_pinned_pool_memory_resource {
pool_size_{rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT)},
pool_{new host_pooled_mr(upstream_mr_, pool_size_, pool_size_)}
{
CUDF_LOG_INFO("Pinned pool size = {}", pool_size_);
CUDF_LOG_INFO("Pinned pool size = %zu", pool_size_);

// Allocate full size from the pinned pool to figure out the beginning and end address
pool_begin_ = pool_->allocate_async(pool_size_, stream_);
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/utilities/stream_pool.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,7 +129,8 @@ class rmm_cuda_stream_pool : public cuda_stream_pool {
std::vector<rmm::cuda_stream_view> get_streams(std::size_t count) override
{
if (count > STREAM_POOL_SIZE) {
CUDF_LOG_WARN("get_streams called with count ({}) > pool size ({})", count, STREAM_POOL_SIZE);
CUDF_LOG_WARN(
"get_streams called with count (%zu) > pool size (%zu)", count, STREAM_POOL_SIZE);
}
auto streams = std::vector<rmm::cuda_stream_view>();
for (uint32_t i = 0; i < count; i++) {
Expand Down

0 comments on commit 5d7686f

Please sign in to comment.