Skip to content

Commit cdb19b3

Browse files
committed
bug logging: remove double timestamp
commit_hash:ea7779bfcaaf15da3b45742aded8eeb7e03751fc
1 parent 461caa4 commit cdb19b3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

core/src/logging/log_message_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <logging/rate_limit.hpp>
1616
#include <userver/decimal64/decimal64.hpp>
1717
#include <userver/formats/json/serialize.hpp>
18+
#include <userver/logging/impl/mem_logger.hpp>
1819
#include <userver/logging/null_logger.hpp>
1920
#include <userver/utils/regex.hpp>
2021
#include <userver/utils/traceful_exception.hpp>
@@ -93,6 +94,17 @@ TEST_F(LoggingTest, LogFormat) {
9394
<< "Path shortening for logs stopped working.";
9495
}
9596

97+
TEST_F(LoggingTest, MemLoggerLogFormat) {
98+
logging::impl::MemLogger mem_logger;
99+
mem_logger.ForwardTo(&*GetStreamLogger());
100+
LOG_CRITICAL_TO(mem_logger) << "test" << logging::LogExtra{{"foo", "bar"}};
101+
logging::LogFlush();
102+
103+
const auto str = GetStreamString();
104+
constexpr std::string_view kTimestamp = "timestamp=";
105+
EXPECT_EQ(str.find(kTimestamp), str.rfind(kTimestamp)) << str;
106+
}
107+
96108
TEST_F(LoggingTest, FloatingPoint) {
97109
constexpr float f = 3.1415F;
98110
EXPECT_EQ(ToStringViaLogging(f), ToStringViaStreams(f));

universal/src/logging/impl/formatters/struct.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ namespace logging::impl::formatters {
1414
Struct::Struct(Level level, LogClass log_class) {
1515
item_.level = level;
1616
item_.log_class = log_class;
17-
18-
const auto now = std::chrono::system_clock::now();
19-
item_.tags.emplace_back(
20-
"timestamp",
21-
fmt::format(FMT_COMPILE("{}.{:06}"), GetCurrentTimeString(now).ToStringView(), FractionalMicroseconds(now))
22-
);
2317
}
2418

2519
void Struct::AddTag(std::string_view key, const LogExtra::Value& value) { item_.tags.emplace_back(key, value); }

0 commit comments

Comments
 (0)