clang-format

This commit is contained in:
gabime
2024-12-01 23:59:09 +02:00
parent 58dac85596
commit e62be8b43f
18 changed files with 69 additions and 85 deletions

View File

@@ -16,7 +16,6 @@
#include "./source_loc.h"
#if defined(SPDLOG_SHARED_LIB)
#if defined(_WIN32)
#ifdef spdlog_EXPORTS

View File

@@ -76,11 +76,10 @@ SPDLOG_API bool is_color_terminal() noexcept;
SPDLOG_API bool in_terminal(FILE *file) noexcept;
#if (defined _WIN32)
SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
SPDLOG_API void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target);
SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
SPDLOG_API void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target);
#endif
// Return directory name from given path or empty string
// "abc/file" => "abc"
// "abc/" => "abc"
@@ -100,7 +99,6 @@ SPDLOG_API std::string getenv(const char *field);
// Return true on success.
SPDLOG_API bool fsync(FILE *fp);
// Do non-locking fwrite if possible by the os or use the regular locking fwrite
// Return true on success.
SPDLOG_API bool fwrite_bytes(const void *ptr, const size_t n_bytes, FILE *fp);

View File

@@ -22,7 +22,6 @@
#include "./details/log_msg.h"
#include "./sinks/sink.h"
#define SPDLOG_LOGGER_CATCH(location) \
catch (const std::exception &ex) { \
if (!location.empty()) { \
@@ -36,7 +35,6 @@
throw; \
}
namespace spdlog {
class SPDLOG_API logger {
@@ -197,7 +195,9 @@ protected:
assert(should_log(msg.log_level));
for (auto &sink : sinks_) {
if (sink->should_log(msg.log_level)) {
try { sink->log(msg); }
try {
sink->log(msg);
}
SPDLOG_LOGGER_CATCH(msg.source)
}
}

View File

@@ -45,9 +45,9 @@ struct daily_filename_calculator {
*/
struct daily_filename_format_calculator {
static filename_t calc_filename(const filename_t &file_path, const tm &now_tm) {
std::stringstream stream;
stream << std::put_time(&now_tm, file_path.c_str());
return stream.str();
std::stringstream stream;
stream << std::put_time(&now_tm, file_path.c_str());
return stream.str();
}
};

View File

@@ -68,17 +68,14 @@ protected:
if (msg.source.empty()) {
// Note: function call inside '()' to avoid macro expansion
err = (sd_journal_send)("MESSAGE=%.*s", static_cast<int>(length), payload.data(), "PRIORITY=%d",
syslog_level(msg.log_level),
"TID=%zu", msg.thread_id,
"SYSLOG_IDENTIFIER=%.*s", static_cast<int>(syslog_identifier.size()),
syslog_identifier.data(), nullptr);
syslog_level(msg.log_level), "TID=%zu", msg.thread_id, "SYSLOG_IDENTIFIER=%.*s",
static_cast<int>(syslog_identifier.size()), syslog_identifier.data(), nullptr);
} else {
err = (sd_journal_send)("MESSAGE=%.*s", static_cast<int>(length), payload.data(), "PRIORITY=%d",
syslog_level(msg.log_level),
"TID=%zu", msg.thread_id,
"SYSLOG_IDENTIFIER=%.*s", static_cast<int>(syslog_identifier.size()),
syslog_identifier.data(), "CODE_FILE=%s", msg.source.filename, "CODE_LINE=%d",
msg.source.line, "CODE_FUNC=%s", msg.source.funcname, nullptr);
syslog_level(msg.log_level), "TID=%zu", msg.thread_id, "SYSLOG_IDENTIFIER=%.*s",
static_cast<int>(syslog_identifier.size()), syslog_identifier.data(), "CODE_FILE=%s",
msg.source.filename, "CODE_LINE=%d", msg.source.line, "CODE_FUNC=%s", msg.source.funcname,
nullptr);
}
if (err) {

View File

@@ -4,7 +4,7 @@
#pragma once
#include <cstdint>
namespace spdlog {// source location
namespace spdlog { // source location
struct source_loc {
constexpr source_loc() = default;
constexpr source_loc(const char *filename_in, std::uint_least32_t line_in, const char *funcname_in)