mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
clang-format
This commit is contained in:
parent
06fb5c7c69
commit
220608e52a
@ -22,19 +22,16 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n, std
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i < threads_n; i++)
|
for (size_t i = 0; i < threads_n; i++)
|
||||||
{
|
{
|
||||||
threads_.emplace_back([this, on_thread_start]
|
threads_.emplace_back([this, on_thread_start] {
|
||||||
{
|
|
||||||
on_thread_start();
|
on_thread_start();
|
||||||
this->thread_pool::worker_loop_();
|
this->thread_pool::worker_loop_();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n):
|
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
|
||||||
thread_pool(q_max_items, threads_n, []{})
|
: thread_pool(q_max_items, threads_n, [] {})
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// message all threads to terminate gracefully join them
|
// message all threads to terminate gracefully join them
|
||||||
SPDLOG_INLINE thread_pool::~thread_pool()
|
SPDLOG_INLINE thread_pool::~thread_pool()
|
||||||
|
@ -40,7 +40,6 @@ public:
|
|||||||
void set_pattern(const std::string &pattern) final;
|
void set_pattern(const std::string &pattern) final;
|
||||||
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) override;
|
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) override;
|
||||||
|
|
||||||
|
|
||||||
// Formatting codes
|
// Formatting codes
|
||||||
const string_view_t reset = "\033[m";
|
const string_view_t reset = "\033[m";
|
||||||
const string_view_t bold = "\033[1m";
|
const string_view_t bold = "\033[1m";
|
||||||
@ -81,7 +80,7 @@ private:
|
|||||||
mutex_t &mutex_;
|
mutex_t &mutex_;
|
||||||
bool should_do_colors_;
|
bool should_do_colors_;
|
||||||
std::unordered_map<level::level_enum, string_view_t, level::level_hasher> colors_;
|
std::unordered_map<level::level_enum, string_view_t, level::level_hasher> colors_;
|
||||||
void print_ccode_(const string_view_t&color_code);
|
void print_ccode_(const string_view_t &color_code);
|
||||||
void print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end);
|
void print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ class syslog_sink : public base_sink<Mutex>
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting):
|
syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting)
|
||||||
enable_formatting_{enable_formatting},
|
: enable_formatting_{enable_formatting}
|
||||||
ident_{std::move(ident)}
|
, ident_{std::move(ident)}
|
||||||
{
|
{
|
||||||
priorities_[static_cast<size_t>(level::trace)] = LOG_DEBUG;
|
priorities_[static_cast<size_t>(level::trace)] = LOG_DEBUG;
|
||||||
priorities_[static_cast<size_t>(level::debug)] = LOG_DEBUG;
|
priorities_[static_cast<size_t>(level::debug)] = LOG_DEBUG;
|
||||||
@ -48,7 +48,7 @@ protected:
|
|||||||
{
|
{
|
||||||
string_view_t payload;
|
string_view_t payload;
|
||||||
|
|
||||||
if(enable_formatting_)
|
if (enable_formatting_)
|
||||||
{
|
{
|
||||||
fmt::memory_buffer formatted;
|
fmt::memory_buffer formatted;
|
||||||
sink::formatter_->format(msg, formatted);
|
sink::formatter_->format(msg, formatted);
|
||||||
@ -86,23 +86,15 @@ using syslog_sink_st = syslog_sink<details::null_mutex>;
|
|||||||
|
|
||||||
// Create and register a syslog logger
|
// Create and register a syslog logger
|
||||||
template<typename Factory = default_factory>
|
template<typename Factory = default_factory>
|
||||||
inline std::shared_ptr<logger> syslog_logger_mt(
|
inline std::shared_ptr<logger> syslog_logger_mt(const std::string &logger_name, const std::string &syslog_ident = "", int syslog_option = 0,
|
||||||
const std::string &logger_name,
|
int syslog_facility = LOG_USER, bool enable_formatting = false)
|
||||||
const std::string &syslog_ident = "",
|
|
||||||
int syslog_option = 0,
|
|
||||||
int syslog_facility = LOG_USER,
|
|
||||||
bool enable_formatting = false)
|
|
||||||
{
|
{
|
||||||
return Factory::template create<sinks::syslog_sink_mt>(logger_name, syslog_ident, syslog_option, syslog_facility, enable_formatting);
|
return Factory::template create<sinks::syslog_sink_mt>(logger_name, syslog_ident, syslog_option, syslog_facility, enable_formatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Factory = default_factory>
|
template<typename Factory = default_factory>
|
||||||
inline std::shared_ptr<logger> syslog_logger_st(
|
inline std::shared_ptr<logger> syslog_logger_st(const std::string &logger_name, const std::string &syslog_ident = "", int syslog_option = 0,
|
||||||
const std::string &logger_name,
|
int syslog_facility = LOG_USER, bool enable_formatting = false)
|
||||||
const std::string &syslog_ident = "",
|
|
||||||
int syslog_option = 0,
|
|
||||||
int syslog_facility = LOG_USER,
|
|
||||||
bool enable_formatting = false)
|
|
||||||
{
|
{
|
||||||
return Factory::template create<sinks::syslog_sink_st>(logger_name, syslog_ident, syslog_option, syslog_facility, enable_formatting);
|
return Factory::template create<sinks::syslog_sink_st>(logger_name, syslog_ident, syslog_option, syslog_facility, enable_formatting);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ inline void critical(const wchar_t *fmt, const Args &... args)
|
|||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (logger->should_log(level)) \
|
if (logger->should_log(level)) \
|
||||||
logger->force_log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \
|
logger->force_log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
|
||||||
|
Loading…
Reference in New Issue
Block a user