Commit 81444265 authored by gabime's avatar gabime

clang-format

parent 5716ab70
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
namespace spdlog { namespace spdlog {
namespace details { namespace details {
SPDLOG_INLINE log_msg::log_msg( SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time, spdlog::source_loc loc, string_view_t a_logger_name,
spdlog::log_clock::time_point log_time, spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) spdlog::level::level_enum lvl, spdlog::string_view_t msg)
: logger_name(a_logger_name) : logger_name(a_logger_name)
, level(lvl) , level(lvl)
, time(log_time) , time(log_time)
......
...@@ -95,7 +95,10 @@ struct null_scoped_padder ...@@ -95,7 +95,10 @@ struct null_scoped_padder
null_scoped_padder(size_t /*wrapped_size*/, const padding_info & /*padinfo*/, memory_buf_t & /*dest*/) {} null_scoped_padder(size_t /*wrapped_size*/, const padding_info & /*padinfo*/, memory_buf_t & /*dest*/) {}
template<typename T> template<typename T>
static unsigned int count_digits(T /* number */) { return 0;} static unsigned int count_digits(T /* number */)
{
return 0;
}
}; };
template<typename ScopedPadder> template<typename ScopedPadder>
...@@ -653,7 +656,6 @@ public: ...@@ -653,7 +656,6 @@ public:
} }
}; };
// Current pid // Current pid
template<typename ScopedPadder> template<typename ScopedPadder>
class pid_formatter final : public flag_formatter class pid_formatter final : public flag_formatter
...@@ -766,7 +768,7 @@ public: ...@@ -766,7 +768,7 @@ public:
} }
size_t text_size; size_t text_size;
if(padinfo_.enabled()) if (padinfo_.enabled())
{ {
// calc text size for padding based on "filename:line" // calc text size for padding based on "filename:line"
text_size = std::char_traits<char>::length(msg.source.filename) + ScopedPadder::count_digits(msg.source.line) + 1; text_size = std::char_traits<char>::length(msg.source.filename) + ScopedPadder::count_digits(msg.source.line) + 1;
...@@ -900,7 +902,6 @@ private: ...@@ -900,7 +902,6 @@ private:
log_clock::time_point last_message_time_; log_clock::time_point last_message_time_;
}; };
// Full info formatter // Full info formatter
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v // pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
class full_formatter final : public flag_formatter class full_formatter final : public flag_formatter
......
This diff is collapsed.
...@@ -4,28 +4,29 @@ ...@@ -4,28 +4,29 @@
TEST_CASE("time_point1", "[time_point log_msg]") TEST_CASE("time_point1", "[time_point log_msg]")
{ {
std::shared_ptr<spdlog::sinks::test_sink_st> test_sink(new spdlog::sinks::test_sink_st); std::shared_ptr<spdlog::sinks::test_sink_st> test_sink(new spdlog::sinks::test_sink_st);
spdlog::logger logger("test-time_point", test_sink); spdlog::logger logger("test-time_point", test_sink);
spdlog::source_loc source{}; spdlog::source_loc source{};
std::chrono::system_clock::time_point tp{std::chrono::system_clock::now()}; std::chrono::system_clock::time_point tp{std::chrono::system_clock::now()};
test_sink->set_pattern("%T.%F"); // interested in the time_point test_sink->set_pattern("%T.%F"); // interested in the time_point
// all the following should have the same time // all the following should have the same time
test_sink->set_delay(std::chrono::milliseconds(10)); test_sink->set_delay(std::chrono::milliseconds(10));
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++)
spdlog::details::log_msg msg{tp,source,"test_logger", spdlog::level::info, "message"}; {
spdlog::details::log_msg msg{tp, source, "test_logger", spdlog::level::info, "message"};
test_sink->log(msg); test_sink->log(msg);
} }
logger.log(tp,source,spdlog::level::info,"formatted message");
logger.log(tp,source,spdlog::level::info,"formatted message");
logger.log(tp,source,spdlog::level::info,"formatted message");
logger.log(tp,source,spdlog::level::info,"formatted message");
logger.log(source,spdlog::level::info,"formatted message"); // last line has different time_point
// now the real test... that the times are the same. logger.log(tp, source, spdlog::level::info, "formatted message");
std::vector<std::string> lines = test_sink->lines(); logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(tp, source, spdlog::level::info, "formatted message");
logger.log(source, spdlog::level::info, "formatted message"); // last line has different time_point
// now the real test... that the times are the same.
std::vector<std::string> lines = test_sink->lines();
REQUIRE(lines[0] == lines[1]); REQUIRE(lines[0] == lines[1]);
REQUIRE(lines[2] == lines[3]); REQUIRE(lines[2] == lines[3]);
REQUIRE(lines[4] == lines[5]); REQUIRE(lines[4] == lines[5]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment