1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-01-15 17:27:57 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Gabi Melman
046fd62dc4
Merge pull request #1337 from luigino/meson
Set version for shared library
2019-11-29 14:41:21 +02:00
Luigi Baldoni
da60dda2dd Set version for shared library 2019-11-29 13:32:41 +01:00
gabime
d25fb08a75 clang-format 2019-11-29 12:50:54 +02:00
gabime
79e105243c Fix #1335 2019-11-29 12:48:21 +02:00
gabime
2d4e531ac9 Fix #1327 2019-11-29 12:36:06 +02:00
gabime
52403ad9ed Fix #1332 2019-11-29 11:32:46 +02:00
6 changed files with 18 additions and 8 deletions

View File

@ -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())

View File

@ -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;

View File

@ -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:

View File

@ -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>

View File

@ -105,6 +105,7 @@ else
include_directories : spdlog_inc,
dependencies : dep_list,
install : not meson.is_subproject(),
version : meson.project_version(),
)
endif

View File

@ -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));