Skip to content

Commit

Permalink
Add missing ext declaration for log detail::format (#1482)
Browse files Browse the repository at this point in the history
The `format` function is used by [debug and trace loggers](https://github.com/rapidsai/raft/blob/a44ca96c5cddec7ca67b510f3c21163d3958bc7e/cpp/include/raft/core/logger-macros.hpp#L44-L75). While PR #1469 has restructured the logger headers it was forgotten to expose `detail::format` in case the `RAFT_EXPLICIT_INSTANTIATE_ONLY` is defined. This PR fixes that.

Authors:
  - Tamas Bela Feher (https://github.com/tfeher)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Allard Hendriksen (https://github.com/ahendriksen)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1482
  • Loading branch information
tfeher authored May 4, 2023
1 parent 3eb30e4 commit 212cfe9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cpp/include/raft/core/logger-ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
*/
#pragma once

#include <memory> // std::unique_ptr
#include <string> // std::string
#include <unordered_map> // std::unordered_map
#include <memory> // std::unique_ptr
#include <raft/core/detail/macros.hpp> // RAFT_INLINE_CONDITIONAL
#include <string> // std::string
#include <unordered_map> // std::unordered_map

namespace raft {

static const std::string RAFT_NAME = "raft";
static const std::string default_log_pattern("[%L] [%H:%M:%S.%f] %v");

namespace detail {
RAFT_INLINE_CONDITIONAL std::string format(const char* fmt, ...);
}
/**
* @brief The main Logging class for raft library.
*
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/core/logger-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ inline std::string format(const char* fmt, va_list& vl)
return std::string(buf.data());
}

inline std::string format(const char* fmt, ...)
RAFT_INLINE_CONDITIONAL std::string format(const char* fmt, ...)
{
va_list vl;
va_start(vl, fmt);
Expand Down
5 changes: 5 additions & 0 deletions cpp/test/core/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
* limitations under the License.
*/

// We set RAFT_ACTIVE_LEVEL to a value that would enable testing trace and debug logs
// (otherwise trace and debug logs are desabled by default).
#undef RAFT_ACTIVE_LEVEL
#define RAFT_ACTIVE_LEVEL 6

#include <gtest/gtest.h>
#include <raft/core/logger.hpp>
#include <string>
Expand Down

0 comments on commit 212cfe9

Please sign in to comment.