mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-28 03:33:51 +00:00
Compare commits
11 Commits
408a2229d6
...
653ec05c0e
Author | SHA1 | Date | |
---|---|---|---|
|
653ec05c0e | ||
|
be2a751513 | ||
|
840adfbbcf | ||
|
3999613eca | ||
|
bff85725d2 | ||
|
93008b2369 | ||
|
be336e7514 | ||
|
255f7f2dee | ||
|
de2c07ac62 | ||
|
844d54d7e6 | ||
|
ff3e6c7248 |
@ -143,7 +143,7 @@ void async_example()
|
|||||||
#include "spdlog/fmt/bin_to_hex.h"
|
#include "spdlog/fmt/bin_to_hex.h"
|
||||||
void binary_example()
|
void binary_example()
|
||||||
{
|
{
|
||||||
std::vector<char> buf;
|
std::vector<char> buf(80);
|
||||||
for (int i = 0; i < 80; i++)
|
for (int i = 0; i < 80; i++)
|
||||||
{
|
{
|
||||||
buf.push_back(static_cast<char>(i & 0xff));
|
buf.push_back(static_cast<char>(i & 0xff));
|
||||||
|
@ -26,7 +26,7 @@ SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other)
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
enabled_ = other.enabled();
|
enabled_ = other.enabled();
|
||||||
messages_ = other.messages_;
|
messages_ = std::move(other.messages_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other)
|
|||||||
update_string_views();
|
update_string_views();
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other)
|
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT
|
||||||
: log_msg{std::move(other)}
|
: log_msg{other}
|
||||||
, buffer{std::move(other.buffer)}
|
, buffer{std::move(other.buffer)}
|
||||||
{
|
{
|
||||||
update_string_views();
|
update_string_views();
|
||||||
@ -42,9 +42,9 @@ SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &ot
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other)
|
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
log_msg::operator=(std::move(other));
|
log_msg::operator=(other);
|
||||||
buffer = std::move(other.buffer);
|
buffer = std::move(other.buffer);
|
||||||
update_string_views();
|
update_string_views();
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -20,9 +20,9 @@ public:
|
|||||||
log_msg_buffer() = default;
|
log_msg_buffer() = default;
|
||||||
explicit log_msg_buffer(const log_msg &orig_msg);
|
explicit log_msg_buffer(const log_msg &orig_msg);
|
||||||
log_msg_buffer(const log_msg_buffer &other);
|
log_msg_buffer(const log_msg_buffer &other);
|
||||||
log_msg_buffer(log_msg_buffer &&other);
|
log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
|
||||||
log_msg_buffer &operator=(const log_msg_buffer &other);
|
log_msg_buffer &operator=(const log_msg_buffer &other);
|
||||||
log_msg_buffer &operator=(log_msg_buffer &&other);
|
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
@ -277,7 +277,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
|
|||||||
return offset;
|
return offset;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined(sun) || defined(__sun) || defined(_AIX)
|
#if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
|
||||||
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
||||||
struct helper
|
struct helper
|
||||||
{
|
{
|
||||||
@ -428,7 +428,7 @@ SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT
|
|||||||
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
||||||
SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
|
SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
|
||||||
{
|
{
|
||||||
if (wstr.size() > static_cast<size_t>(std::numeric_limits<int>::max()))
|
if (wstr.size() > static_cast<size_t>((std::numeric_limits<int>::max())))
|
||||||
{
|
{
|
||||||
SPDLOG_THROW(spdlog::spdlog_ex("UTF-16 string is too big to be converted to UTF-8"));
|
SPDLOG_THROW(spdlog::spdlog_ex("UTF-16 string is too big to be converted to UTF-8"));
|
||||||
}
|
}
|
||||||
|
@ -593,14 +593,7 @@ public:
|
|||||||
const size_t field_size = 6;
|
const size_t field_size = 6;
|
||||||
ScopedPadder p(field_size, padinfo_, dest);
|
ScopedPadder p(field_size, padinfo_, dest);
|
||||||
|
|
||||||
#ifdef _WIN32
|
auto total_minutes = get_cached_offset(msg, tm_time);
|
||||||
int total_minutes = get_cached_offset(msg, tm_time);
|
|
||||||
#else
|
|
||||||
// No need to cache under gcc,
|
|
||||||
// it is very fast (already stored in tm.tm_gmtoff)
|
|
||||||
(void)(msg);
|
|
||||||
int total_minutes = os::utc_minutes_offset(tm_time);
|
|
||||||
#endif
|
|
||||||
bool is_negative = total_minutes < 0;
|
bool is_negative = total_minutes < 0;
|
||||||
if (is_negative)
|
if (is_negative)
|
||||||
{
|
{
|
||||||
@ -619,7 +612,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
log_clock::time_point last_update_{std::chrono::seconds(0)};
|
log_clock::time_point last_update_{std::chrono::seconds(0)};
|
||||||
#ifdef _WIN32
|
|
||||||
int offset_minutes_{0};
|
int offset_minutes_{0};
|
||||||
|
|
||||||
int get_cached_offset(const log_msg &msg, const std::tm &tm_time)
|
int get_cached_offset(const log_msg &msg, const std::tm &tm_time)
|
||||||
@ -632,7 +624,6 @@ private:
|
|||||||
}
|
}
|
||||||
return offset_minutes_;
|
return offset_minutes_;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Thread id
|
// Thread id
|
||||||
@ -885,7 +876,7 @@ public:
|
|||||||
fmt_helper::pad6(static_cast<size_t>(delta_units.count()), dest);
|
fmt_helper::pad6(static_cast<size_t>(delta_units.count()), dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
log_clock::time_point last_message_time_;
|
log_clock::time_point last_message_time_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ SPDLOG_INLINE std::vector<sink_ptr> &logger::sinks()
|
|||||||
// error handler
|
// error handler
|
||||||
SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
|
SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
|
||||||
{
|
{
|
||||||
custom_err_handler_ = handler;
|
custom_err_handler_ = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new logger with same sinks and configuration.
|
// create new logger with same sinks and configuration.
|
||||||
|
@ -1,4 +1,17 @@
|
|||||||
Checks: 'modernize-*,modernize-use-override,google-*,-google-runtime-references,misc-*,clang-analyzer-*,-misc-non-private-member-variables-in-classes, -modernize-use-trailing-return-type'
|
Checks: '\
|
||||||
|
cppcoreguidelines-*,\
|
||||||
|
performance-*,\
|
||||||
|
-performance-unnecessary-value-param,\
|
||||||
|
modernize-*,\
|
||||||
|
-modernize-use-trailing-return-type,\
|
||||||
|
google-*,\
|
||||||
|
-google-runtime-references,\
|
||||||
|
misc-*,\
|
||||||
|
-misc-non-private-member-variables-in-classes,\
|
||||||
|
cert-*,\
|
||||||
|
readability-*,\
|
||||||
|
clang-analyzer-*'
|
||||||
|
|
||||||
WarningsAsErrors: ''
|
WarningsAsErrors: ''
|
||||||
HeaderFilterRegex: 'async.h|async_logger.h|common.h|details|formatter.h|logger.h|sinks|spdlog.h|tweakme.h|version.h'
|
HeaderFilterRegex: 'async.h|async_logger.h|common.h|details|formatter.h|logger.h|sinks|spdlog.h|tweakme.h|version.h'
|
||||||
AnalyzeTemporaryDtors: false
|
AnalyzeTemporaryDtors: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user