File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
universal/src/logging/impl/formatters Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 15
15
#include < logging/rate_limit.hpp>
16
16
#include < userver/decimal64/decimal64.hpp>
17
17
#include < userver/formats/json/serialize.hpp>
18
+ #include < userver/logging/impl/mem_logger.hpp>
18
19
#include < userver/logging/null_logger.hpp>
19
20
#include < userver/utils/regex.hpp>
20
21
#include < userver/utils/traceful_exception.hpp>
@@ -93,6 +94,17 @@ TEST_F(LoggingTest, LogFormat) {
93
94
<< " Path shortening for logs stopped working." ;
94
95
}
95
96
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
+
96
108
TEST_F (LoggingTest, FloatingPoint) {
97
109
constexpr float f = 3 .1415F ;
98
110
EXPECT_EQ (ToStringViaLogging (f), ToStringViaStreams (f));
Original file line number Diff line number Diff line change @@ -14,12 +14,6 @@ namespace logging::impl::formatters {
14
14
Struct::Struct (Level level, LogClass log_class) {
15
15
item_.level = level;
16
16
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
- );
23
17
}
24
18
25
19
void Struct::AddTag (std::string_view key, const LogExtra::Value& value) { item_.tags .emplace_back (key, value); }
You can’t perform that action at this time.
0 commit comments