mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-15 17:27:57 +00:00
Compare commits
6 Commits
2d264855cc
...
046fd62dc4
Author | SHA1 | Date | |
---|---|---|---|
|
046fd62dc4 | ||
|
da60dda2dd | ||
|
d25fb08a75 | ||
|
79e105243c | ||
|
2d4e531ac9 | ||
|
52403ad9ed |
@ -12,7 +12,8 @@
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg)
|
||||
SPDLOG_INLINE log_msg::log_msg(
|
||||
spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg)
|
||||
: logger_name(a_logger_name)
|
||||
, level(lvl)
|
||||
, time(os::now())
|
||||
|
@ -230,7 +230,12 @@ SPDLOG_INLINE size_t filesize(FILE *f)
|
||||
#endif
|
||||
|
||||
#else // unix
|
||||
// OpenBSD doesn't compile with :: before the fileno(..)
|
||||
#if defined(__OpenBSD__)
|
||||
int fd = fileno(f);
|
||||
#else
|
||||
int fd = ::fileno(f);
|
||||
#endif
|
||||
// 64 bits(but not in osx or cygwin, where fstat64 is deprecated)
|
||||
#if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
|
||||
struct stat64 st;
|
||||
|
@ -875,8 +875,10 @@ public:
|
||||
auto delta = (std::max)(msg.time - last_message_time_, log_clock::duration::zero());
|
||||
auto delta_units = std::chrono::duration_cast<DurationUnits>(delta);
|
||||
last_message_time_ = msg.time;
|
||||
ScopedPadder p(6, padinfo_, dest);
|
||||
fmt_helper::pad6(static_cast<size_t>(delta_units.count()), dest);
|
||||
auto delta_count = static_cast<size_t>(delta_units.count());
|
||||
auto n_digits = static_cast<size_t>(fmt_helper::count_digits(delta_count));
|
||||
ScopedPadder p(n_digits, padinfo_, dest);
|
||||
fmt_helper::append_int(delta_count, dest);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <spdlog/details/os.h>
|
||||
#include <spdlog/details/circular_q.h>
|
||||
#include <spdlog/details/synchronous_factory.h>
|
||||
|
||||
#include <chrono>
|
||||
|
@ -105,6 +105,7 @@ else
|
||||
include_directories : spdlog_inc,
|
||||
dependencies : dep_list,
|
||||
install : not meson.is_subproject(),
|
||||
version : meson.project_version(),
|
||||
)
|
||||
endif
|
||||
|
||||
|
@ -193,19 +193,19 @@ TEST_CASE("center_padded_short", "[pattern_formatter]")
|
||||
TEST_CASE("left_padded_huge", "[pattern_formatter]")
|
||||
{
|
||||
REQUIRE(log_to_str("Some message", "[%-300n] %v", spdlog::pattern_time_type::local, "\n") ==
|
||||
"[pattern_tester ] Some message\n");
|
||||
"[pattern_tester ] Some message\n");
|
||||
|
||||
REQUIRE(log_to_str("Some message", "[%-300!n] %v", spdlog::pattern_time_type::local, "\n") ==
|
||||
"[pattern_tester ] Some message\n");
|
||||
"[pattern_tester ] Some message\n");
|
||||
}
|
||||
|
||||
TEST_CASE("left_padded_max", "[pattern_formatter]")
|
||||
{
|
||||
REQUIRE(log_to_str("Some message", "[%-64n] %v", spdlog::pattern_time_type::local, "\n") ==
|
||||
"[pattern_tester ] Some message\n");
|
||||
"[pattern_tester ] Some message\n");
|
||||
|
||||
REQUIRE(log_to_str("Some message", "[%-64!n] %v", spdlog::pattern_time_type::local, "\n") ==
|
||||
"[pattern_tester ] Some message\n");
|
||||
"[pattern_tester ] Some message\n");
|
||||
}
|
||||
|
||||
// Test padding + truncate flag
|
||||
@ -231,7 +231,7 @@ TEST_CASE("paddinng_truncate_funcname", "[pattern_formatter]")
|
||||
{
|
||||
spdlog::sinks::test_sink_st test_sink;
|
||||
|
||||
const char* pattern = "%v [%5!!]";
|
||||
const char *pattern = "%v [%5!!]";
|
||||
auto formatter = std::unique_ptr<spdlog::formatter>(new spdlog::pattern_formatter(pattern));
|
||||
test_sink.set_formatter(std::move(formatter));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user