Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/common/common/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class EscapeMessageJsonString : public spdlog::custom_flag_formatter {

#define ENVOY_LOG_EVENT_TO_LOGGER(LOGGER, LEVEL, EVENT_NAME, ...) \
do { \
ENVOY_LOG(LEVEL, ##__VA_ARGS__); \
ENVOY_LOG_TO_LOGGER(LOGGER, LEVEL, ##__VA_ARGS__); \
if (ENVOY_LOG_COMP_LEVEL(LOGGER, LEVEL)) { \
::Envoy::Logger::Registry::getSink()->logWithStableName(EVENT_NAME, #LEVEL, (LOGGER).name(), \
##__VA_ARGS__); \
Expand Down
6 changes: 6 additions & 0 deletions test/common/common/logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "gtest/gtest.h"

using testing::_;
using testing::Invoke;

namespace Envoy {
namespace Logger {
Expand Down Expand Up @@ -177,6 +178,11 @@ TEST_F(NamedLogTest, NamedLogsAreSentToSink) {
EXPECT_CALL(sink, log(_));
EXPECT_CALL(sink, logWithStableName("test_event", "debug", "assert", "test log 1"));
ENVOY_LOG_EVENT(debug, "test_event", "test {} {}", "log", 1);

// Verify that ENVOY_LOG_EVENT_TO_LOGGER does the right thing.
EXPECT_CALL(sink, log(_)).WillOnce(Invoke([](auto log) { EXPECT_TRUE(log.find("[misc]")); }));
EXPECT_CALL(sink, logWithStableName("misc_event", "debug", "misc", "log"));
ENVOY_LOG_EVENT_TO_LOGGER(Registry::getLog(Id::misc), debug, "misc_event", "log");
}

} // namespace Logger
Expand Down