Clang format

This commit is contained in:
gabime 2024-04-30 12:28:13 +03:00
parent 37b847692e
commit 22b0f4fc06
12 changed files with 53 additions and 61 deletions

View File

@ -98,7 +98,7 @@ SPDLOG_INLINE void file_helper::close() {
} }
SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf) { SPDLOG_INLINE void file_helper::write(const memory_buf_t &buf) {
if(fd_ == nullptr) return; if (fd_ == nullptr) return;
size_t msg_size = buf.size(); size_t msg_size = buf.size();
auto data = buf.data(); auto data = buf.data();
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) { if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {

View File

@ -84,7 +84,6 @@ SPDLOG_INLINE std::shared_ptr<logger> registry::get(const std::string &logger_na
return found == loggers_.end() ? nullptr : found->second; return found == loggers_.end() ? nullptr : found->second;
} }
SPDLOG_INLINE std::shared_ptr<logger> registry::default_logger() { SPDLOG_INLINE std::shared_ptr<logger> registry::default_logger() {
std::lock_guard<std::mutex> lock(logger_map_mutex_); std::lock_guard<std::mutex> lock(logger_map_mutex_);
return default_logger_; return default_logger_;

View File

@ -44,7 +44,8 @@ public:
// set default logger and add it to the registry if not registered already. // set default logger and add it to the registry if not registered already.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map. // default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
// Note: Make sure to unregister it when no longer needed or before calling again with a new logger. // Note: Make sure to unregister it when no longer needed or before calling again with a new
// logger.
void set_default_logger(std::shared_ptr<logger> new_default_logger); void set_default_logger(std::shared_ptr<logger> new_default_logger);
void set_tp(std::shared_ptr<thread_pool> tp); void set_tp(std::shared_ptr<thread_pool> tp);

View File

@ -67,9 +67,7 @@ struct async_msg : log_msg_buffer {
worker_ptr{std::move(worker)}, worker_ptr{std::move(worker)},
flush_promise{} {} flush_promise{} {}
async_msg(async_logger_ptr &&worker, async_msg(async_logger_ptr &&worker, async_msg_type the_type, std::promise<void> &&promise)
async_msg_type the_type,
std::promise<void> &&promise)
: log_msg_buffer{}, : log_msg_buffer{},
msg_type{the_type}, msg_type{the_type},
worker_ptr{std::move(worker)}, worker_ptr{std::move(worker)},

View File

@ -6,8 +6,8 @@
#include <spdlog/common.h> #include <spdlog/common.h>
namespace spdlog { namespace spdlog {
class SPDLOG_API mdc { class SPDLOG_API mdc {
public: public:
using mdc_map_t = std::map<std::string, std::string>; using mdc_map_t = std::map<std::string, std::string>;
static void put(const std::string &key, const std::string &value) { static void put(const std::string &key, const std::string &value) {
@ -31,6 +31,6 @@ namespace spdlog {
static thread_local mdc_map_t context; static thread_local mdc_map_t context;
return context; return context;
} }
}; };
} // namespace spdlog } // namespace spdlog

View File

@ -802,7 +802,7 @@ public:
} }
} }
void format_mdc(const mdc::mdc_map_t &mdc_map, memory_buf_t &dest){ void format_mdc(const mdc::mdc_map_t &mdc_map, memory_buf_t &dest) {
auto last_element = --mdc_map.end(); auto last_element = --mdc_map.end();
for (auto it = mdc_map.begin(); it != mdc_map.end(); ++it) { for (auto it = mdc_map.begin(); it != mdc_map.end(); ++it) {
auto &pair = *it; auto &pair = *it;
@ -825,8 +825,6 @@ public:
} }
}; };
// Full info formatter // Full info formatter
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v // pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] [%s:%#] %v
class full_formatter final : public flag_formatter { class full_formatter final : public flag_formatter {
@ -921,8 +919,6 @@ private:
mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info{}}; mdc_formatter<null_scoped_padder> mdc_formatter_{padding_info{}};
}; };
} // namespace details } // namespace details
SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern, SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern,

View File

@ -20,7 +20,6 @@ SPDLOG_INLINE std::shared_ptr<logger> get(const std::string &name) {
return details::registry::instance().get(name); return details::registry::instance().get(name);
} }
SPDLOG_INLINE void set_formatter(std::unique_ptr<spdlog::formatter> formatter) { SPDLOG_INLINE void set_formatter(std::unique_ptr<spdlog::formatter> formatter) {
details::registry::instance().set_formatter(std::move(formatter)); details::registry::instance().set_formatter(std::move(formatter));
} }

View File

@ -84,11 +84,11 @@ TEST_CASE("dir_name", "[create_dir]") {
#ifdef _WIN32 #ifdef _WIN32
// //
// test windows cases when drive letter is given e.g. C:\\some-folder // test windows cases when drive letter is given e.g. C:\\some-folder
// //
#include <windows.h> #include <windows.h>
#include <fileapi.h> #include <fileapi.h>
std::string get_full_path(const std::string &relative_folder_path) { std::string get_full_path(const std::string &relative_folder_path) {
char full_path[MAX_PATH]; char full_path[MAX_PATH];
@ -109,7 +109,7 @@ spdlog::filename_t::value_type find_non_existing_drive() {
std::string root_path = std::string(1, drive) + ":\\"; std::string root_path = std::string(1, drive) + ":\\";
UINT drive_type = GetDriveTypeA(root_path.c_str()); UINT drive_type = GetDriveTypeA(root_path.c_str());
if (drive_type == DRIVE_NO_ROOT_DIR) { if (drive_type == DRIVE_NO_ROOT_DIR) {
return static_cast <spdlog::filename_t::value_type>(drive); return static_cast<spdlog::filename_t::value_type>(drive);
} }
} }
return '\0'; // No available drive found return '\0'; // No available drive found
@ -134,12 +134,11 @@ TEST_CASE("non_existing_drive", "[create_dir]") {
spdlog::filename_t path; spdlog::filename_t path;
auto non_existing_drive = find_non_existing_drive(); auto non_existing_drive = find_non_existing_drive();
path += non_existing_drive ; path += non_existing_drive;
path += SPDLOG_FILENAME_T(":\\"); path += SPDLOG_FILENAME_T(":\\");
REQUIRE(create_dir(path) == false); REQUIRE(create_dir(path) == false);
path += SPDLOG_FILENAME_T("subdir"); path += SPDLOG_FILENAME_T("subdir");
REQUIRE(create_dir(path) == false); REQUIRE(create_dir(path) == false);
} }
//#endif // SPDLOG_WCHAR_FILENAMES // #endif // SPDLOG_WCHAR_FILENAMES
#endif // _WIN32 #endif // _WIN32