update clang format again

This commit is contained in:
gabime
2023-09-25 16:40:36 +03:00
parent 251c856a12
commit 0a53eafe18
104 changed files with 713 additions and 734 deletions

View File

@@ -59,5 +59,5 @@ SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log
messages_.pop_front();
}
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -37,8 +37,8 @@ public:
void foreach_pop(std::function<void(const details::log_msg &)> fun);
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "backtracer-inl.h"

View File

@@ -24,7 +24,7 @@ public:
circular_q() = default;
explicit circular_q(size_t max_items)
: max_items_(max_items + 1) // one item is reserved as marker for full q
: max_items_(max_items + 1) // one item is reserved as marker for full q
,
v_(max_items_) {}
@@ -46,7 +46,7 @@ public:
v_[tail_] = std::move(item);
tail_ = (tail_ + 1) % max_items_;
if (tail_ == head_) // overrun last item if full
if (tail_ == head_) // overrun last item if full
{
head_ = (head_ + 1) % max_items_;
++overrun_counter_;
@@ -109,5 +109,5 @@ private:
other.overrun_counter_ = 0;
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -24,5 +24,5 @@ struct console_nullmutex {
return s_mutex;
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -127,8 +127,8 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const { return filename_
// ".mylog" => (".mylog". "")
// "my_folder/.mylog" => ("my_folder/.mylog", "")
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
SPDLOG_INLINE std::tuple<filename_t, filename_t>
file_helper::split_by_extension(const filename_t &fname) {
SPDLOG_INLINE std::tuple<filename_t, filename_t> file_helper::split_by_extension(
const filename_t &fname) {
auto ext_index = fname.rfind('.');
// no valid extension found - return whole path and empty string as
@@ -147,5 +147,5 @@ file_helper::split_by_extension(const filename_t &fname) {
return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index));
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -53,8 +53,8 @@ private:
filename_t filename_;
file_event_handlers event_handlers_;
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "file_helper-inl.h"

View File

@@ -53,14 +53,10 @@ SPDLOG_CONSTEXPR_FUNC unsigned int count_digits_fallback(T n) {
// Integer division is slow so do it for a group of four digits instead
// of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison.
if (n < 10)
return count;
if (n < 100)
return count + 1;
if (n < 1000)
return count + 2;
if (n < 10000)
return count + 3;
if (n < 10) return count;
if (n < 100) return count + 1;
if (n < 1000) return count + 2;
if (n < 10000) return count + 3;
n /= 10000u;
count += 4;
}
@@ -86,11 +82,11 @@ inline unsigned int count_digits(T n) {
}
inline void pad2(int n, memory_buf_t &dest) {
if (n >= 0 && n < 100) // 0-99
if (n >= 0 && n < 100) // 0-99
{
dest.push_back(static_cast<char>('0' + n / 10));
dest.push_back(static_cast<char>('0' + n % 10));
} else // unlikely, but just in case, let fmt deal with it
} else // unlikely, but just in case, let fmt deal with it
{
fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n);
}
@@ -140,6 +136,6 @@ inline ToDuration time_fraction(log_clock::time_point tp) {
return duration_cast<ToDuration>(duration) - duration_cast<ToDuration>(secs);
}
} // namespace fmt_helper
} // namespace details
} // namespace spdlog
} // namespace fmt_helper
} // namespace details
} // namespace spdlog

View File

@@ -40,5 +40,5 @@ SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name,
spdlog::string_view_t msg)
: log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) {}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -32,8 +32,8 @@ struct SPDLOG_API log_msg {
source_loc source;
string_view_t payload;
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg-inl.h"

View File

@@ -50,5 +50,5 @@ SPDLOG_INLINE void log_msg_buffer::update_string_views() {
payload = string_view_t{buffer.data() + logger_name.size(), payload.size()};
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -24,8 +24,8 @@ public:
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg_buffer-inl.h"

View File

@@ -173,5 +173,5 @@ private:
spdlog::details::circular_q<T> q_;
std::atomic<size_t> discard_counter_{0};
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -27,9 +27,9 @@ struct null_atomic_int {
int exchange(int new_value, std::memory_order = std::memory_order_relaxed) {
std::swap(new_value, value);
return new_value; // return value before the call
return new_value; // return value before the call
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -23,9 +23,9 @@
#ifdef _WIN32
#include <spdlog/details/windows_include.h>
#include <fileapi.h> // for FlushFileBuffers
#include <io.h> // for _get_osfhandle, _isatty, _fileno
#include <process.h> // for _get_pid
#include <fileapi.h> // for FlushFileBuffers
#include <io.h> // for _get_osfhandle, _isatty, _fileno
#include <process.h> // for _get_pid
#ifdef __MINGW32__
#include <share.h>
@@ -36,37 +36,37 @@
#include <limits>
#endif
#include <direct.h> // for _mkdir/_wmkdir
#include <direct.h> // for _mkdir/_wmkdir
#else // unix
#else // unix
#include <fcntl.h>
#include <unistd.h>
#ifdef __linux__
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#elif defined(_AIX)
#include <pthread.h> // for pthread_getthrds_np
#include <pthread.h> // for pthread_getthrds_np
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <pthread_np.h> // for pthread_getthreadid_np
#include <pthread_np.h> // for pthread_getthreadid_np
#elif defined(__NetBSD__)
#include <lwp.h> // for _lwp_self
#include <lwp.h> // for _lwp_self
#elif defined(__sun)
#include <thread.h> // for thr_self
#include <thread.h> // for thr_self
#endif
#endif // unix
#endif // unix
#if defined __APPLE__
#include <AvailabilityMacros.h>
#endif
#ifndef __has_feature // Clang - feature checking macros.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#ifndef __has_feature // Clang - feature checking macros.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
namespace spdlog {
@@ -74,7 +74,6 @@ namespace details {
namespace os {
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
timespec ts;
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
@@ -87,7 +86,6 @@ SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT {
#endif
}
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
#ifdef _WIN32
std::tm tm;
::localtime_s(&tm, &time_tt);
@@ -104,7 +102,6 @@ SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT {
}
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT {
#ifdef _WIN32
std::tm tm;
::gmtime_s(&tm, &time_tt);
@@ -137,7 +134,7 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename
}
}
#endif
#else // unix
#else // unix
#if defined(SPDLOG_PREVENT_CHILD_FD)
const int mode_flag = mode == SPDLOG_FILENAME_T("ab") ? O_APPEND : O_TRUNC;
const int fd =
@@ -186,7 +183,7 @@ SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT {
auto attribs = ::GetFileAttributesA(filename.c_str());
#endif
return attribs != INVALID_FILE_ATTRIBUTES;
#else // common linux/unix all have the stat system call
#else // common linux/unix all have the stat system call
struct stat buffer;
return (::stat(filename.c_str(), &buffer) == 0);
#endif
@@ -205,20 +202,20 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
}
#if defined(_WIN32) && !defined(__CYGWIN__)
int fd = ::_fileno(f);
#if defined(_WIN64) // 64 bits
#if defined(_WIN64) // 64 bits
__int64 ret = ::_filelengthi64(fd);
if (ret >= 0) {
return static_cast<size_t>(ret);
}
#else // windows 32 bits
#else // windows 32 bits
long ret = ::_filelength(fd);
if (ret >= 0) {
return static_cast<size_t>(ret);
}
#endif
#else // unix
#else // unix
// OpenBSD and AIX doesn't compile with :: before the fileno(..)
#if defined(__OpenBSD__) || defined(_AIX)
int fd = fileno(f);
@@ -232,7 +229,7 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
if (::fstat64(fd, &st) == 0) {
return static_cast<size_t>(st.st_size);
}
#else // other unix or linux 32 bits or cygwin
#else // other unix or linux 32 bits or cygwin
struct stat st;
if (::fstat(fd, &st) == 0) {
return static_cast<size_t>(st.st_size);
@@ -240,7 +237,7 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
#endif
#endif
throw_spdlog_ex("Failed getting file size from fd", errno);
return 0; // will not be reached.
return 0; // will not be reached.
}
#ifdef _MSC_VER
@@ -249,7 +246,6 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
// Return utc offset in minutes or throw spdlog_ex on failure
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
#ifdef _WIN32
#if _WIN32_WINNT < _WIN32_WINNT_WS08
TIME_ZONE_INFORMATION tzinfo;
@@ -258,8 +254,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
#endif
if (rv == TIME_ZONE_ID_INVALID)
throw_spdlog_ex("Failed getting timezone info. ", errno);
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
int offset = -tzinfo.Bias;
if (tm.tm_isdst) {
@@ -351,7 +346,7 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT {
pthread_threadid_np(nullptr, &tid);
#endif
return static_cast<size_t>(tid);
#else // Default to standard C++11 (other Unix)
#else // Default to standard C++11 (other Unix)
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
#endif
}
@@ -360,7 +355,7 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT {
SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT {
#if defined(SPDLOG_NO_TLS)
return _thread_id();
#else // cache thread id in tls
#else // cache thread id in tls
static thread_local const size_t tid = _thread_id();
return tid;
#endif
@@ -388,7 +383,6 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return f
#endif
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT {
#ifdef _WIN32
return conditional_static_cast<int>(::GetCurrentProcessId());
#else
@@ -430,7 +424,6 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT {
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT {
#ifdef _WIN32
return ::_isatty(_fileno(file)) != 0;
#else
@@ -499,8 +492,8 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target) {
throw_spdlog_ex(
fmt_lib::format("MultiByteToWideChar failed. Last error: {}", ::GetLastError()));
}
#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) &&
// defined(_WIN32)
#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) &&
// defined(_WIN32)
// return true on success
static SPDLOG_INLINE bool mkdir_(const filename_t &path) {
@@ -537,7 +530,7 @@ SPDLOG_INLINE bool create_dir(const filename_t &path) {
auto subdir = path.substr(0, token_pos);
if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir)) {
return false; // return error if failed creating dir
return false; // return error if failed creating dir
}
search_offset = token_pos + 1;
} while (search_offset < path.size());
@@ -556,17 +549,16 @@ SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
}
std::string SPDLOG_INLINE getenv(const char *field) {
#if defined(_MSC_VER)
#if defined(__cplusplus_winrt)
return std::string{}; // not supported under uwp
return std::string{}; // not supported under uwp
#else
size_t len = 0;
char buf[128];
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#endif
#else // revert to getenv
#else // revert to getenv
char *buf = ::getenv(field);
return buf ? buf : std::string{};
#endif
@@ -582,6 +574,6 @@ SPDLOG_INLINE bool fsync(FILE *fp) {
#endif
}
} // namespace os
} // namespace details
} // namespace spdlog
} // namespace os
} // namespace details
} // namespace spdlog

View File

@@ -3,7 +3,7 @@
#pragma once
#include <ctime> // std::time_t
#include <ctime> // std::time_t
#include <spdlog/common.h>
namespace spdlog {
@@ -114,9 +114,9 @@ SPDLOG_API std::string getenv(const char *field);
// Return true on success.
SPDLOG_API bool fsync(FILE *fp);
} // namespace os
} // namespace details
} // namespace spdlog
} // namespace os
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "os-inl.h"

View File

@@ -22,5 +22,5 @@ SPDLOG_INLINE periodic_worker::~periodic_worker() {
}
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -32,7 +32,7 @@ public:
for (;;) {
std::unique_lock<std::mutex> lock(this->mutex_);
if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) {
return; // active_ == false, so exit this thread
return; // active_ == false, so exit this thread
}
callback_fun();
}
@@ -49,8 +49,8 @@ private:
std::mutex mutex_;
std::condition_variable cv_;
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "periodic_worker-inl.h"

View File

@@ -19,7 +19,7 @@
#else
#include <spdlog/sinks/ansicolor_sink.h>
#endif
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
#include <chrono>
#include <functional>
@@ -32,7 +32,6 @@ namespace details {
SPDLOG_INLINE registry::registry()
: formatter_(new pattern_formatter()) {
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
#ifdef _WIN32
@@ -45,7 +44,7 @@ SPDLOG_INLINE registry::registry()
default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink));
loggers_[default_logger_name] = default_logger_;
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
}
SPDLOG_INLINE registry::~registry() = default;
@@ -170,8 +169,8 @@ SPDLOG_INLINE void registry::set_error_handler(err_handler handler) {
err_handler_ = std::move(handler);
}
SPDLOG_INLINE void
registry::apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun) {
SPDLOG_INLINE void registry::apply_all(
const std::function<void(const std::shared_ptr<logger>)> &fun) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
for (auto &l : loggers_) {
fun(l.second);
@@ -262,5 +261,5 @@ SPDLOG_INLINE void registry::register_logger_(std::shared_ptr<logger> new_logger
loggers_[logger_name] = std::move(new_logger);
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -114,8 +114,8 @@ private:
size_t backtrace_n_messages_ = 0;
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "registry-inl.h"

View File

@@ -19,4 +19,4 @@ struct synchronous_factory {
return new_logger;
}
};
} // namespace spdlog
} // namespace spdlog

View File

@@ -66,9 +66,9 @@ public:
struct addrinfo hints {};
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
hints.ai_socktype = SOCK_STREAM; // TCP
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
hints.ai_socktype = SOCK_STREAM; // TCP
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
hints.ai_protocol = 0;
auto port_str = std::to_string(port);
@@ -123,7 +123,7 @@ public:
throw_winsock_error_("send failed", last_error);
}
if (write_result == 0) // (probably should not happen but in any case..)
if (write_result == 0) // (probably should not happen but in any case..)
{
break;
}
@@ -131,5 +131,5 @@ public:
}
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -44,9 +44,9 @@ public:
close();
struct addrinfo hints {};
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
hints.ai_socktype = SOCK_STREAM; // TCP
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on
hints.ai_socktype = SOCK_STREAM; // TCP
hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value
hints.ai_protocol = 0;
auto port_str = std::to_string(port);
@@ -115,7 +115,7 @@ public:
throw_spdlog_ex("write(2) failed", errno);
}
if (write_result == 0) // (probably should not happen but in any case..)
if (write_result == 0) // (probably should not happen but in any case..)
{
break;
}
@@ -123,5 +123,5 @@ public:
}
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -19,8 +19,9 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items,
std::function<void()> on_thread_stop)
: q_(q_max_items) {
if (threads_n == 0 || threads_n > 1000) {
throw_spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid "
"range is 1-1000)");
throw_spdlog_ex(
"spdlog::thread_pool(): invalid threads_n param (valid "
"range is 1-1000)");
}
for (size_t i = 0; i < threads_n; i++) {
threads_.emplace_back([this, on_thread_start, on_thread_stop] {
@@ -101,26 +102,26 @@ bool SPDLOG_INLINE thread_pool::process_next_msg_() {
q_.dequeue(incoming_async_msg);
switch (incoming_async_msg.msg_type) {
case async_msg_type::log: {
incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg);
return true;
}
case async_msg_type::flush: {
incoming_async_msg.worker_ptr->backend_flush_();
return true;
}
case async_msg_type::log: {
incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg);
return true;
}
case async_msg_type::flush: {
incoming_async_msg.worker_ptr->backend_flush_();
return true;
}
case async_msg_type::terminate: {
return false;
}
case async_msg_type::terminate: {
return false;
}
default: {
assert(false);
}
default: {
assert(false);
}
}
return true;
}
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -47,7 +47,7 @@ struct async_msg : log_msg_buffer {
worker_ptr = std::move(other.worker_ptr);
return *this;
}
#else // (_MSC_VER) && _MSC_VER <= 1800
#else // (_MSC_VER) && _MSC_VER <= 1800
async_msg(async_msg &&) = default;
async_msg &operator=(async_msg &&) = default;
#endif
@@ -109,8 +109,8 @@ private:
bool process_next_msg_();
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "thread_pool-inl.h"

View File

@@ -94,5 +94,5 @@ public:
}
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -77,5 +77,5 @@ public:
}
}
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -1,7 +1,7 @@
#pragma once
#ifndef NOMINMAX
#define NOMINMAX // prevent windows redefining min/max
#define NOMINMAX // prevent windows redefining min/max
#endif
#ifndef WIN32_LEAN_AND_MEAN