Skip to content

Commit

Permalink
[common] Adjust non-spdlog stub to be more generous (RobotLocomotion#…
Browse files Browse the repository at this point in the history
…21864)

Calls that used fmt_runtime were not being stubbed correctly.
  • Loading branch information
jwnimmer-tri authored Sep 3, 2024
1 parent 2433131 commit e61a396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
3 changes: 2 additions & 1 deletion common/test/text_logging_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ GTEST_TEST(TextLoggingTest, ConstantTest) {
}

// Check that the "warn once" idiom compiles and doesn't crash at runtime.
// We use a pattern substitution to cover both arguments of the Warn's ctor.
GTEST_TEST(TextLoggingTest, WarnOnceTest) {
static const drake::logging::Warn log_once(
"The log_once happened as expected.");
"The {} happened as expected.", "log_once");
}

// Abuse gtest internals to verify that logging actually prints when enabled,
Expand Down
25 changes: 6 additions & 19 deletions common/text_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,17 @@ class logger {
logger();

template <typename... Args>
void trace(const char*, const Args&...) {}
void trace(const Args&...) {}
template <typename... Args>
void debug(const char*, const Args&...) {}
void debug(const Args&...) {}
template <typename... Args>
void info(const char*, const Args&...) {}
void info(const Args&...) {}
template <typename... Args>
void warn(const char*, const Args&...) {}
void warn(const Args&...) {}
template <typename... Args>
void error(const char*, const Args&...) {}
void error(const Args&...) {}
template <typename... Args>
void critical(const char*, const Args&...) {}

template <typename T>
void trace(const T&) {}
template <typename T>
void debug(const T&) {}
template <typename T>
void info(const T&) {}
template <typename T>
void warn(const T&) {}
template <typename T>
void error(const T&) {}
template <typename T>
void critical(const T&) {}
void critical(const Args&...) {}
};

// A stubbed-out version of `spdlog::sinks::sink`.
Expand Down

0 comments on commit e61a396

Please sign in to comment.