code format

This commit is contained in:
gabime
2025-01-17 20:59:46 +02:00
parent b9f0243405
commit 47fe6ef92a
23 changed files with 68 additions and 76 deletions

View File

@@ -6,13 +6,13 @@
#include <array>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <exception>
#include <functional>
#include <initializer_list>
#include <memory>
#include <string>
#include <string_view>
#include <cstdint>
#include "./source_loc.h"
#include "fmt/base.h"

View File

@@ -4,29 +4,27 @@
#pragma once
#include <cstdint>
#include "./log_msg.h"
namespace spdlog {
namespace details {
// Extend log_msg with internal buffer to store its payload.
// This is needed since log_msg holds string_views that points to stack data.
class SPDLOG_API async_log_msg : public log_msg {
public:
enum class type:std::uint8_t { log, flush, terminate };
enum class type : std::uint8_t { log, flush, terminate };
async_log_msg() = default;
explicit async_log_msg(type type);
async_log_msg(type type, const log_msg &orig_msg);
~async_log_msg() = default;
async_log_msg(const async_log_msg &other);
async_log_msg(async_log_msg &&other) noexcept;
async_log_msg &operator=(const async_log_msg &other);
async_log_msg &operator=(async_log_msg &&other) noexcept;
[[nodiscard]] type message_type() const { return msg_type_; }
type message_type() const {return msg_type_;}
private:
type msg_type_{type::log};
memory_buf_t buffer_;

View File

@@ -3,10 +3,11 @@
#pragma once
#include <string>
#include <chrono>
#include <exception>
#include <mutex>
#include <string>
#include "spdlog/common.h"
// by default, prints the error to stderr, at max rate of 1/sec thread safe
@@ -16,6 +17,7 @@ class SPDLOG_API err_helper {
err_handler custom_err_handler_;
std::chrono::steady_clock::time_point last_report_time_;
mutable std::mutex mutex_;
public:
err_helper() = default;
~err_helper() = default;
@@ -25,5 +27,5 @@ public:
void handle_unknown_ex(const std::string& origin, const source_loc& loc) noexcept;
void set_err_handler(err_handler handler);
};
} // namespace details
} // namespace spdlog
} // namespace details
} // namespace spdlog

View File

@@ -42,7 +42,7 @@ public:
logger(std::string name, sinks_init_list sinks)
: logger(std::move(name), sinks.begin(), sinks.end()) {}
logger(const logger &other) ;
logger(const logger &other);
logger(logger &&other) noexcept;
~logger() = default;

View File

@@ -91,14 +91,13 @@ public:
return std::make_shared<async_sink>(cfg);
}
private:
using async_log_msg = details::async_log_msg;
using queue_t = details::mpmc_blocking_queue<async_log_msg>;
void enqueue_message_(details::async_log_msg &&msg) const;
void backend_loop_();
void backend_log_(const details::log_msg &msg) ;
void backend_log_(const details::log_msg &msg);
void backend_flush_();
config config_;

View File

@@ -16,11 +16,11 @@
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/uri.hpp>
#include <mutex>
#include "../details/null_mutex.h"
#include "../common.h"
#include "../details/log_msg.h"
#include "../details/null_mutex.h"
#include "./base_sink.h"
namespace spdlog {

View File

@@ -4,6 +4,7 @@
#pragma once
#include <mutex>
#include "../details/null_mutex.h"
#include "./base_sink.h"

View File

@@ -46,7 +46,9 @@ public:
}
protected:
void sink_it_(const details::log_msg &msg) override { q_.push_back(details::async_log_msg{details::async_log_msg::type::log, msg}); }
void sink_it_(const details::log_msg &msg) override {
q_.push_back(details::async_log_msg{details::async_log_msg::type::log, msg});
}
void flush_() override {}
private:

View File

@@ -17,8 +17,8 @@ public:
virtual void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) = 0;
void set_level(level level) { level_.store(level, std::memory_order_relaxed); }
level log_level() const { return level_.load(std::memory_order_relaxed);}
bool should_log(level msg_level) const {return msg_level >= level_.load(std::memory_order_relaxed);}
level log_level() const { return level_.load(std::memory_order_relaxed); }
bool should_log(level msg_level) const { return msg_level >= level_.load(std::memory_order_relaxed); }
protected:
// sink log level - default is all

View File

@@ -8,8 +8,8 @@
#include <syslog.h>
#include <array>
#include <string>
#include <mutex>
#include <string>
namespace spdlog {
namespace sinks {
@@ -19,7 +19,7 @@ namespace sinks {
template <typename Mutex>
class syslog_sink final : public base_sink<Mutex> {
public:
syslog_sink(std::string ident = "", int syslog_option = 0, int syslog_facility = LOG_USER, bool enable_formatting=false)
syslog_sink(std::string ident = "", int syslog_option = 0, int syslog_facility = LOG_USER, bool enable_formatting = false)
: enable_formatting_{enable_formatting},
syslog_levels_{{/* spdlog::level::trace */ LOG_DEBUG,
/* spdlog::level::debug */ LOG_DEBUG,