clang format and SPLDOG_HEADER_ONLY macro

This commit is contained in:
gabime 2019-05-12 00:22:39 +03:00
parent 540f865355
commit 6bcb422c80
37 changed files with 227 additions and 249 deletions

View File

@ -32,9 +32,9 @@ BraceWrapping:
BeforeCatch: true BeforeCatch: true
BeforeElse: true BeforeElse: true
IndentBraces: false IndentBraces: false
SplitEmptyFunction: true SplitEmptyFunction: false
SplitEmptyRecord: true SplitEmptyRecord: false
SplitEmptyNamespace: true SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false BreakBeforeInheritanceComma: false

View File

@ -60,7 +60,7 @@ message(STATUS "Static lib: " ${SPDLOG_STATIC_LIB})
if(SPDLOG_STATIC_LIB) if(SPDLOG_STATIC_LIB)
add_definitions(-DSPDLOG_STATIC_LIB) add_definitions(-DSPDLOG_STATIC_LIB)
set(SRC_BASE "${CMAKE_CURRENT_SOURCE_DIR}/src") set(SRC_BASE "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(SRC_FILES "${SRC_BASE}/spdlog.cpp" "${SRC_BASE}/format.cc") set(SRC_FILES "${SRC_BASE}/spdlog.cpp" "${SRC_BASE}/format.cpp")
add_library(spdlog STATIC ${SRC_FILES}) add_library(spdlog STATIC ${SRC_FILES})
target_include_directories(spdlog PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>") target_include_directories(spdlog PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
target_link_libraries(spdlog -Wl,--as-needed) target_link_libraries(spdlog -Wl,--as-needed)

View File

@ -7,10 +7,15 @@
// //
// //
#include "spdlog/spdlog.h" //#include "spdlog/spdlog.h"
#include "spdlog/logger.h"
//#include "spdlog/sinks/stdout_color_sinks.h"
int main(int, char *[]) int main(int, char *[])
{ {
int i = 123; spdlog::logger *l = nullptr;
spdlog::info("HELLO STATIC! {}", i); const int i = 123;
l->info("HELLO STATIC! {}", i);
l->info("HELLO STATIC! {}", "GABI");
l->info("HELLO STATIC! {} {}", "GABI", i);
l->warn("HELLO STATIC! {} {}", "GABI", i);
} }

View File

@ -16,20 +16,17 @@ SPDLOG_INLINE spdlog::async_logger::async_logger(
: logger(std::move(logger_name), begin, end) : logger(std::move(logger_name), begin, end)
, thread_pool_(std::move(tp)) , thread_pool_(std::move(tp))
, overflow_policy_(overflow_policy) , overflow_policy_(overflow_policy)
{ {}
}
SPDLOG_INLINE spdlog::async_logger::async_logger( SPDLOG_INLINE spdlog::async_logger::async_logger(
std::string logger_name, sinks_init_list sinks_list, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy) std::string logger_name, sinks_init_list sinks_list, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy)
: async_logger(std::move(logger_name), sinks_list.begin(), sinks_list.end(), std::move(tp), overflow_policy) : async_logger(std::move(logger_name), sinks_list.begin(), sinks_list.end(), std::move(tp), overflow_policy)
{ {}
}
SPDLOG_INLINE spdlog::async_logger::async_logger( SPDLOG_INLINE spdlog::async_logger::async_logger(
std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy) std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy)
: async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) : async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy)
{ {}
}
// send the log message to the thread pool // send the log message to the thread pool
SPDLOG_INLINE void spdlog::async_logger::sink_it_(details::log_msg &msg) SPDLOG_INLINE void spdlog::async_logger::sink_it_(details::log_msg &msg)

View File

@ -60,6 +60,6 @@ private:
}; };
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "async_logger-inl.h" #include "async_logger-inl.h"
#endif #endif

View File

@ -1,23 +1,53 @@
// Copyright(c) 2015-present Gabi Melman & spdlog contributors. // Copyright(c) 2015-present Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT) // Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once #pragma once
namespace spdlog {
namespace level {
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
SPDLOG_INLINE spdlog::spdlog_ex::spdlog_ex(std::string msg) static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
: msg_(std::move(msg))
SPDLOG_INLINE string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
{ {
return level_string_views[l];
} }
SPDLOG_INLINE spdlog::spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
{
return short_level_names[l];
}
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
{
int level = 0;
for (const auto &level_str : level_string_views)
{
if (level_str == name)
{
return static_cast<level::level_enum>(level);
}
level++;
}
return level::off;
}
} // namespace level
SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
: msg_(std::move(msg))
{}
SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
{ {
fmt::memory_buffer outbuf; fmt::memory_buffer outbuf;
fmt::format_system_error(outbuf, last_errno, msg); fmt::format_system_error(outbuf, last_errno, msg);
msg_ = fmt::to_string(outbuf); msg_ = fmt::to_string(outbuf);
} }
SPDLOG_INLINE const char *spdlog::spdlog_ex::what() const SPDLOG_NOEXCEPT SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT
{ {
return msg_.c_str(); return msg_.c_str();
} }
} // namespace spdlog

View File

@ -22,8 +22,10 @@
#include "spdlog/fmt/fmt.h" #include "spdlog/fmt/fmt.h"
#ifdef SPDLOG_STATIC_LIB #ifdef SPDLOG_STATIC_LIB
#undef SPDLOG_HEADER_ONLY
#define SPDLOG_INLINE #define SPDLOG_INLINE
#else #else
#define SPDLOG_HEADER_ONLY
#define SPDLOG_INLINE inline #define SPDLOG_INLINE inline
#endif #endif
@ -138,39 +140,18 @@ enum level_enum
"trace", "debug", "info", "warning", "error", "critical", "off" \ "trace", "debug", "info", "warning", "error", "critical", "off" \
} }
#endif #endif
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
#if !defined(SPDLOG_SHORT_LEVEL_NAMES) #if !defined(SPDLOG_SHORT_LEVEL_NAMES)
#define SPDLOG_SHORT_LEVEL_NAMES \ #define SPDLOG_SHORT_LEVEL_NAMES \
{ \ { \
"T", "D", "I", "W", "E", "C", "O" \ "T", "D", "I", "W", "E", "C", "O" \
} }
#endif #endif
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
inline string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
{ const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
return level_string_views[l]; spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT;
}
inline const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
{
return short_level_names[l];
}
inline spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
{
int level = 0;
for (const auto &level_str : level_string_views)
{
if (level_str == name)
{
return static_cast<level::level_enum>(level);
}
level++;
}
return level::off;
}
using level_hasher = std::hash<int>; using level_hasher = std::hash<int>;
} // namespace level } // namespace level
@ -206,8 +187,7 @@ struct source_loc
: filename{filename_in} : filename{filename_in}
, line{line_in} , line{line_in}
, funcname{funcname_in} , funcname{funcname_in}
{ {}
}
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT
{ {
@ -234,6 +214,6 @@ std::unique_ptr<T> make_unique(Args &&... args)
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "commont-inl.h" #include "common-inl.h"
#endif #endif

View File

@ -17,8 +17,7 @@ public:
explicit circular_q(size_t max_items) 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_) , v_(max_items_)
{ {}
}
// push back, overrun (oldest) item if no room left // push back, overrun (oldest) item if no room left
void push_back(T &&item) void push_back(T &&item)

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include "spdlog/details/null_mutex.h" #include "spdlog/details/null_mutex.h"
#include <cstdio> #include <cstdio>
#include <mutex> #include <mutex>

View File

@ -14,6 +14,7 @@
namespace spdlog { namespace spdlog {
namespace details { namespace details {
SPDLOG_INLINE file_helper::~file_helper() SPDLOG_INLINE file_helper::~file_helper()
{ {
close(); close();

View File

@ -55,6 +55,6 @@ private:
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "file_helper-inl.h" #include "file_helper-inl.h"
#endif #endif

View File

@ -6,7 +6,10 @@
#include "spdlog/details/os.h" #include "spdlog/details/os.h"
#include "spdlog/sinks/sink.h" #include "spdlog/sinks/sink.h"
SPDLOG_INLINE spdlog::details::log_msg::log_msg( namespace spdlog {
namespace details {
SPDLOG_INLINE log_msg::log_msg(
spdlog::source_loc loc, const std::string *loggers_name, spdlog::level::level_enum lvl, spdlog::string_view_t view) spdlog::source_loc loc, const std::string *loggers_name, spdlog::level::level_enum lvl, spdlog::string_view_t view)
: logger_name(loggers_name) : logger_name(loggers_name)
, level(lvl) , level(lvl)
@ -19,10 +22,11 @@ SPDLOG_INLINE spdlog::details::log_msg::log_msg(
#endif #endif
, source(loc) , source(loc)
, payload(view) , payload(view)
{ {}
}
SPDLOG_INLINE spdlog::details::log_msg::log_msg(const std::string *loggers_name, spdlog::level::level_enum lvl, spdlog::string_view_t view) SPDLOG_INLINE log_msg::log_msg(const std::string *loggers_name, spdlog::level::level_enum lvl, spdlog::string_view_t view)
: log_msg(source_loc{}, loggers_name, lvl, view) : log_msg(source_loc{}, loggers_name, lvl, view)
{ {}
}
} // namespace details
} // namespace spdlog

View File

@ -11,7 +11,6 @@ namespace details {
struct log_msg struct log_msg
{ {
log_msg(source_loc loc, const std::string *loggers_name, level::level_enum lvl, string_view_t view); log_msg(source_loc loc, const std::string *loggers_name, level::level_enum lvl, string_view_t view);
log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view); log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view);
log_msg(const log_msg &other) = default; log_msg(const log_msg &other) = default;
@ -31,6 +30,6 @@ struct log_msg
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "log_msg-inl.h" #include "log_msg-inl.h"
#endif #endif

View File

@ -25,8 +25,7 @@ public:
using item_type = T; using item_type = T;
explicit mpmc_blocking_queue(size_t max_items) explicit mpmc_blocking_queue(size_t max_items)
: q_(max_items) : q_(max_items)
{ {}
}
#ifndef __MINGW32__ #ifndef __MINGW32__
// try to enqueue and block if no room left // try to enqueue and block if no room left

View File

@ -25,8 +25,7 @@ struct null_atomic_int
explicit null_atomic_int(int val) explicit null_atomic_int(int val)
: value(val) : value(val)
{ {}
}
int load(std::memory_order) const int load(std::memory_order) const
{ {

View File

@ -88,6 +88,6 @@ void wbuf_to_utf8buf(const fmt::wmemory_buffer &wbuf, fmt::memory_buffer &target
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "os-inl.h" #include "os-inl.h"
#endif #endif

View File

@ -58,8 +58,7 @@ public:
scoped_pad(spdlog::string_view_t txt, padding_info &padinfo, fmt::memory_buffer &dest) scoped_pad(spdlog::string_view_t txt, padding_info &padinfo, fmt::memory_buffer &dest)
: scoped_pad(txt.size(), padinfo, dest) : scoped_pad(txt.size(), padinfo, dest)
{ {}
}
~scoped_pad() ~scoped_pad()
{ {
@ -90,8 +89,7 @@ class name_formatter : public flag_formatter
public: public:
explicit name_formatter(padding_info padinfo) explicit name_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -113,8 +111,7 @@ class level_formatter : public flag_formatter
public: public:
explicit level_formatter(padding_info padinfo) explicit level_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -137,8 +134,7 @@ class short_level_formatter : public flag_formatter
public: public:
explicit short_level_formatter(padding_info padinfo) explicit short_level_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -169,8 +165,7 @@ class a_formatter : public flag_formatter
public: public:
explicit a_formatter(padding_info padinfo) explicit a_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -187,8 +182,7 @@ class A_formatter : public flag_formatter
public: public:
explicit A_formatter(padding_info padinfo) explicit A_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -205,8 +199,7 @@ class b_formatter : public flag_formatter
public: public:
explicit b_formatter(padding_info padinfo) explicit b_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -224,8 +217,7 @@ class B_formatter : public flag_formatter
public: public:
explicit B_formatter(padding_info padinfo) explicit B_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -241,8 +233,7 @@ class c_formatter final : public flag_formatter
public: public:
explicit c_formatter(padding_info padinfo) explicit c_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -273,8 +264,7 @@ class C_formatter final : public flag_formatter
public: public:
explicit C_formatter(padding_info padinfo) explicit C_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -290,8 +280,7 @@ class D_formatter final : public flag_formatter
public: public:
explicit D_formatter(padding_info padinfo) explicit D_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -327,8 +316,7 @@ class m_formatter final : public flag_formatter
public: public:
explicit m_formatter(padding_info padinfo) explicit m_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -344,8 +332,7 @@ class d_formatter final : public flag_formatter
public: public:
explicit d_formatter(padding_info padinfo) explicit d_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -361,8 +348,7 @@ class H_formatter final : public flag_formatter
public: public:
explicit H_formatter(padding_info padinfo) explicit H_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
@ -707,8 +693,7 @@ class ch_formatter final : public flag_formatter
public: public:
explicit ch_formatter(char ch) explicit ch_formatter(char ch)
: ch_(ch) : ch_(ch)
{ {}
}
void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -746,8 +731,7 @@ class color_start_formatter final : public flag_formatter
public: public:
explicit color_start_formatter(padding_info padinfo) explicit color_start_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -759,8 +743,7 @@ class color_stop_formatter final : public flag_formatter
public: public:
explicit color_stop_formatter(padding_info padinfo) explicit color_stop_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
@ -864,8 +847,7 @@ class full_formatter final : public flag_formatter
public: public:
explicit full_formatter(padding_info padinfo) explicit full_formatter(padding_info padinfo)
: flag_formatter(padinfo) : flag_formatter(padinfo)
{ {}
}
void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {

View File

@ -6,7 +6,6 @@
#include "spdlog/common.h" #include "spdlog/common.h"
#include "spdlog/details/log_msg.h" #include "spdlog/details/log_msg.h"
#include "spdlog/details/os.h" #include "spdlog/details/os.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/formatter.h" #include "spdlog/formatter.h"
#include <chrono> #include <chrono>
@ -33,8 +32,7 @@ struct padding_info
padding_info(size_t width, padding_info::pad_side side) padding_info(size_t width, padding_info::pad_side side)
: width_(width) : width_(width)
, side_(side) , side_(side)
{ {}
}
bool enabled() const bool enabled() const
{ {
@ -49,8 +47,7 @@ class flag_formatter
public: public:
explicit flag_formatter(padding_info padinfo) explicit flag_formatter(padding_info padinfo)
: padinfo_(padinfo) : padinfo_(padinfo)
{ {}
}
flag_formatter() = default; flag_formatter() = default;
virtual ~flag_formatter() = default; virtual ~flag_formatter() = default;
virtual void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) = 0; virtual void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) = 0;
@ -83,8 +80,8 @@ private:
std::tm cached_tm_; std::tm cached_tm_;
std::chrono::seconds last_log_secs_; std::chrono::seconds last_log_secs_;
std::vector<std::unique_ptr<details::flag_formatter>> formatters_; std::vector<std::unique_ptr<details::flag_formatter>> formatters_;
std::tm get_time_(const details::log_msg &msg);
std::tm get_time_(const details::log_msg &msg);
void handle_flag_(char flag, details::padding_info padding); void handle_flag_(char flag, details::padding_info padding);
// Extract given pad spec (e.g. %8X) // Extract given pad spec (e.g. %8X)
@ -96,6 +93,6 @@ private:
}; };
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "pattern_formatter-inl.h" #include "pattern_formatter-inl.h"
#endif #endif

View File

@ -2,8 +2,9 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT) // Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once #pragma once
namespace spdlog {
SPDLOG_INLINE spdlog::details::periodic_worker::periodic_worker(const std::function<void()> &callback_fun, std::chrono::seconds interval) namespace details {
SPDLOG_INLINE periodic_worker::periodic_worker(const std::function<void()> &callback_fun, std::chrono::seconds interval)
{ {
active_ = (interval > std::chrono::seconds::zero()); active_ = (interval > std::chrono::seconds::zero());
if (!active_) if (!active_)
@ -25,7 +26,7 @@ SPDLOG_INLINE spdlog::details::periodic_worker::periodic_worker(const std::funct
} }
// stop the worker thread and join it // stop the worker thread and join it
SPDLOG_INLINE spdlog::details::periodic_worker::~periodic_worker() SPDLOG_INLINE periodic_worker::~periodic_worker()
{ {
if (worker_thread_.joinable()) if (worker_thread_.joinable())
{ {
@ -37,3 +38,6 @@ SPDLOG_INLINE spdlog::details::periodic_worker::~periodic_worker()
worker_thread_.join(); worker_thread_.join();
} }
} }
} // namespace details
} // namespace spdlog

View File

@ -35,6 +35,6 @@ private:
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "periodic_worker-inl.h" #include "periodic_worker-inl.h"
#endif #endif

View File

@ -99,6 +99,6 @@ private:
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "registry-inl.h" #include "registry-inl.h"
#endif #endif

View File

@ -5,7 +5,9 @@
#include "spdlog/common.h" #include "spdlog/common.h"
SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size_t threads_n) namespace spdlog {
namespace details {
SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
: q_(q_max_items) : q_(q_max_items)
{ {
if (threads_n == 0 || threads_n > 1000) if (threads_n == 0 || threads_n > 1000)
@ -20,7 +22,7 @@ SPDLOG_INLINE spdlog::details::thread_pool::thread_pool(size_t q_max_items, size
} }
// message all threads to terminate gracefully join them // message all threads to terminate gracefully join them
SPDLOG_INLINE spdlog::details::thread_pool::~thread_pool() SPDLOG_INLINE thread_pool::~thread_pool()
{ {
try try
{ {
@ -35,28 +37,26 @@ SPDLOG_INLINE spdlog::details::thread_pool::~thread_pool()
} }
} }
catch (...) catch (...)
{ {}
}
} }
void SPDLOG_INLINE spdlog::details::thread_pool::post_log( void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy)
async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy)
{ {
async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg); async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg);
post_async_msg_(std::move(async_m), overflow_policy); post_async_msg_(std::move(async_m), overflow_policy);
} }
void SPDLOG_INLINE spdlog::details::thread_pool::post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy) void SPDLOG_INLINE thread_pool::post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy)
{ {
post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy); post_async_msg_(async_msg(std::move(worker_ptr), async_msg_type::flush), overflow_policy);
} }
size_t SPDLOG_INLINE spdlog::details::thread_pool::overrun_counter() size_t SPDLOG_INLINE thread_pool::overrun_counter()
{ {
return q_.overrun_counter(); return q_.overrun_counter();
} }
void SPDLOG_INLINE spdlog::details::thread_pool::post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy) void SPDLOG_INLINE thread_pool::post_async_msg_(async_msg &&new_msg, async_overflow_policy overflow_policy)
{ {
if (overflow_policy == async_overflow_policy::block) if (overflow_policy == async_overflow_policy::block)
{ {
@ -68,7 +68,7 @@ void SPDLOG_INLINE spdlog::details::thread_pool::post_async_msg_(async_msg &&new
} }
} }
void SPDLOG_INLINE spdlog::details::thread_pool::worker_loop_() void SPDLOG_INLINE thread_pool::worker_loop_()
{ {
while (process_next_msg_()) {}; while (process_next_msg_()) {};
} }
@ -76,7 +76,7 @@ void SPDLOG_INLINE spdlog::details::thread_pool::worker_loop_()
// process next message in the queue // process next message in the queue
// return true if this thread should still be active (while no terminate msg // return true if this thread should still be active (while no terminate msg
// was received) // was received)
bool SPDLOG_INLINE spdlog::details::thread_pool::process_next_msg_() bool SPDLOG_INLINE thread_pool::process_next_msg_()
{ {
async_msg incoming_async_msg; async_msg incoming_async_msg;
bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10)); bool dequeued = q_.dequeue_for(incoming_async_msg, std::chrono::seconds(10));
@ -107,3 +107,6 @@ bool SPDLOG_INLINE spdlog::details::thread_pool::process_next_msg_()
assert(false && "Unexpected async_msg_type"); assert(false && "Unexpected async_msg_type");
return true; return true;
} }
} // namespace details
} // namespace spdlog

View File

@ -57,8 +57,7 @@ struct async_msg
msg_id(other.msg_id), msg_id(other.msg_id),
source(other.source), source(other.source),
worker_ptr(std::move(other.worker_ptr)) worker_ptr(std::move(other.worker_ptr))
{ {}
}
async_msg &operator=(async_msg &&other) SPDLOG_NOEXCEPT async_msg &operator=(async_msg &&other) SPDLOG_NOEXCEPT
{ {
@ -98,13 +97,11 @@ struct async_msg
, msg_id(0) , msg_id(0)
, source() , source()
, worker_ptr(std::move(worker)) , worker_ptr(std::move(worker))
{ {}
}
explicit async_msg(async_msg_type the_type) explicit async_msg(async_msg_type the_type)
: async_msg(nullptr, the_type) : async_msg(nullptr, the_type)
{ {}
}
// copy into log_msg // copy into log_msg
log_msg to_log_msg() log_msg to_log_msg()
@ -154,6 +151,6 @@ private:
} // namespace details } // namespace details
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "thread_pool-inl.h" #include "thread_pool-inl.h"
#endif #endif

View File

@ -31,8 +31,7 @@ public:
bytes_range(It range_begin, It range_end) bytes_range(It range_begin, It range_end)
: begin_(range_begin) : begin_(range_begin)
, end_(range_end) , end_(range_end)
{ {}
}
It begin() const It begin() const
{ {

View File

@ -11,7 +11,7 @@
// //
#if !defined(SPDLOG_FMT_EXTERNAL) #if !defined(SPDLOG_FMT_EXTERNAL)
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY #ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY #define FMT_HEADER_ONLY
#endif #endif

View File

@ -6,8 +6,9 @@
#include "spdlog/sinks/sink.h" #include "spdlog/sinks/sink.h"
#include "spdlog/details/pattern_formatter.h" #include "spdlog/details/pattern_formatter.h"
namespace spdlog {
// public methods // public methods
SPDLOG_INLINE void spdlog::logger::log(spdlog::source_loc loc, spdlog::level::level_enum lvl, const char *msg) SPDLOG_INLINE void logger::log(source_loc loc, level::level_enum lvl, const char *msg)
{ {
if (!should_log(lvl)) if (!should_log(lvl))
{ {
@ -16,7 +17,7 @@ SPDLOG_INLINE void spdlog::logger::log(spdlog::source_loc loc, spdlog::level::le
try try
{ {
details::log_msg log_msg(loc, &name_, lvl, spdlog::string_view_t(msg)); details::log_msg log_msg(loc, &name_, lvl, string_view_t(msg));
sink_it_(log_msg); sink_it_(log_msg);
} }
catch (const std::exception &ex) catch (const std::exception &ex)
@ -29,39 +30,39 @@ SPDLOG_INLINE void spdlog::logger::log(spdlog::source_loc loc, spdlog::level::le
} }
} }
SPDLOG_INLINE void spdlog::logger::log(level::level_enum lvl, const char *msg) SPDLOG_INLINE void logger::log(level::level_enum lvl, const char *msg)
{ {
log(source_loc{}, lvl, msg); log(source_loc{}, lvl, msg);
} }
SPDLOG_INLINE bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) const SPDLOG_INLINE bool logger::should_log(level::level_enum msg_level) const
{ {
return msg_level >= level_.load(std::memory_order_relaxed); return msg_level >= level_.load(std::memory_order_relaxed);
} }
SPDLOG_INLINE void spdlog::logger::set_level(spdlog::level::level_enum log_level) SPDLOG_INLINE void logger::set_level(level::level_enum log_level)
{ {
level_.store(log_level); level_.store(log_level);
} }
SPDLOG_INLINE spdlog::level::level_enum spdlog::logger::default_level() SPDLOG_INLINE level::level_enum logger::default_level()
{ {
return static_cast<spdlog::level::level_enum>(SPDLOG_ACTIVE_LEVEL); return static_cast<level::level_enum>(SPDLOG_ACTIVE_LEVEL);
} }
SPDLOG_INLINE spdlog::level::level_enum spdlog::logger::level() const SPDLOG_INLINE level::level_enum logger::level() const
{ {
return static_cast<spdlog::level::level_enum>(level_.load(std::memory_order_relaxed)); return static_cast<level::level_enum>(level_.load(std::memory_order_relaxed));
} }
SPDLOG_INLINE const std::string &spdlog::logger::name() const SPDLOG_INLINE const std::string &logger::name() const
{ {
return name_; return name_;
} }
// set formatting for the sinks in this logger. // set formatting for the sinks in this logger.
// each sink will get a seperate instance of the formatter object. // each sink will get a seperate instance of the formatter object.
SPDLOG_INLINE void spdlog::logger::set_formatter(std::unique_ptr<spdlog::formatter> f) SPDLOG_INLINE void logger::set_formatter(std::unique_ptr<formatter> f)
{ {
for (auto &sink : sinks_) for (auto &sink : sinks_)
{ {
@ -69,14 +70,14 @@ SPDLOG_INLINE void spdlog::logger::set_formatter(std::unique_ptr<spdlog::formatt
} }
} }
SPDLOG_INLINE void spdlog::logger::set_pattern(std::string pattern, spdlog::pattern_time_type time_type) SPDLOG_INLINE void logger::set_pattern(std::string pattern, pattern_time_type time_type)
{ {
auto new_formatter = details::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type); auto new_formatter = details::make_unique<pattern_formatter>(std::move(pattern), time_type);
set_formatter(std::move(new_formatter)); set_formatter(std::move(new_formatter));
} }
// flush functions // flush functions
SPDLOG_INLINE void spdlog::logger::flush() SPDLOG_INLINE void logger::flush()
{ {
try try
{ {
@ -92,37 +93,37 @@ SPDLOG_INLINE void spdlog::logger::flush()
} }
} }
SPDLOG_INLINE void spdlog::logger::flush_on(level::level_enum log_level) SPDLOG_INLINE void logger::flush_on(level::level_enum log_level)
{ {
flush_level_.store(log_level); flush_level_.store(log_level);
} }
SPDLOG_INLINE spdlog::level::level_enum spdlog::logger::flush_level() const SPDLOG_INLINE level::level_enum logger::flush_level() const
{ {
return static_cast<spdlog::level::level_enum>(flush_level_.load(std::memory_order_relaxed)); return static_cast<level::level_enum>(flush_level_.load(std::memory_order_relaxed));
} }
// sinks // sinks
SPDLOG_INLINE const std::vector<spdlog::sink_ptr> &spdlog::logger::sinks() const SPDLOG_INLINE const std::vector<sink_ptr> &logger::sinks() const
{ {
return sinks_; return sinks_;
} }
SPDLOG_INLINE std::vector<spdlog::sink_ptr> &spdlog::logger::sinks() SPDLOG_INLINE std::vector<sink_ptr> &logger::sinks()
{ {
return sinks_; return sinks_;
} }
// error handler // error handler
SPDLOG_INLINE void spdlog::logger::set_error_handler(err_handler handler) SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
{ {
custom_err_handler_ = handler; custom_err_handler_ = handler;
} }
// create new logger with same sinks and configuration. // create new logger with same sinks and configuration.
SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::logger::clone(std::string logger_name) SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
{ {
auto cloned = std::make_shared<spdlog::logger>(std::move(logger_name), sinks_.begin(), sinks_.end()); auto cloned = std::make_shared<logger>(std::move(logger_name), sinks_.begin(), sinks_.end());
cloned->set_level(this->level()); cloned->set_level(this->level());
cloned->flush_on(this->flush_level()); cloned->flush_on(this->flush_level());
cloned->set_error_handler(this->custom_err_handler_); cloned->set_error_handler(this->custom_err_handler_);
@ -130,7 +131,7 @@ SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::logger::clone(std::string
} }
// protected methods // protected methods
SPDLOG_INLINE void spdlog::logger::sink_it_(spdlog::details::log_msg &msg) SPDLOG_INLINE void logger::sink_it_(details::log_msg &msg)
{ {
for (auto &sink : sinks_) for (auto &sink : sinks_)
{ {
@ -146,7 +147,7 @@ SPDLOG_INLINE void spdlog::logger::sink_it_(spdlog::details::log_msg &msg)
} }
} }
SPDLOG_INLINE void spdlog::logger::flush_() SPDLOG_INLINE void logger::flush_()
{ {
for (auto &sink : sinks_) for (auto &sink : sinks_)
{ {
@ -154,13 +155,13 @@ SPDLOG_INLINE void spdlog::logger::flush_()
} }
} }
SPDLOG_INLINE bool spdlog::logger::should_flush_(const spdlog::details::log_msg &msg) SPDLOG_INLINE bool logger::should_flush_(const details::log_msg &msg)
{ {
auto flush_level = flush_level_.load(std::memory_order_relaxed); auto flush_level = flush_level_.load(std::memory_order_relaxed);
return (msg.level >= flush_level) && (msg.level != level::off); return (msg.level >= flush_level) && (msg.level != level::off);
} }
SPDLOG_INLINE void spdlog::logger::err_handler_(const std::string &msg) SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
{ {
if (custom_err_handler_) if (custom_err_handler_)
{ {
@ -168,9 +169,10 @@ SPDLOG_INLINE void spdlog::logger::err_handler_(const std::string &msg)
} }
else else
{ {
auto tm_time = spdlog::details::os::localtime(); auto tm_time = details::os::localtime();
char date_buf[64]; char date_buf[64];
std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
fmt::print(stderr, "[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, name(), msg); fmt::print(stderr, "[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf, name(), msg);
} }
} }
} // namespace spdlog

View File

@ -35,17 +35,14 @@ public:
logger(std::string name, It begin, It end) logger(std::string name, It begin, It end)
: name_(std::move(name)) : name_(std::move(name))
, sinks_(begin, end) , sinks_(begin, end)
{ {}
}
logger(std::string name, sink_ptr single_sink) logger(std::string name, sink_ptr single_sink)
: logger(std::move(name), {std::move(single_sink)}) : logger(std::move(name), {std::move(single_sink)})
{ {}
}
logger(std::string name, sinks_init_list sinks) logger(std::string name, sinks_init_list sinks)
: logger(std::move(name), sinks.begin(), sinks.end()) : logger(std::move(name), sinks.begin(), sinks.end())
{ {}
}
virtual ~logger() = default; virtual ~logger() = default;
@ -338,6 +335,6 @@ protected:
}; };
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "logger-inl.h" #include "logger-inl.h"
#endif #endif

View File

@ -35,8 +35,7 @@ public:
explicit android_sink(std::string tag = "spdlog", bool use_raw_msg = false) explicit android_sink(std::string tag = "spdlog", bool use_raw_msg = false)
: tag_(std::move(tag)) : tag_(std::move(tag))
, use_raw_msg_(use_raw_msg) , use_raw_msg_(use_raw_msg)
{ {}
}
protected: protected:
void sink_it_(const details::log_msg &msg) override void sink_it_(const details::log_msg &msg) override

View File

@ -89,6 +89,6 @@ using ansicolor_stderr_sink_st = ansicolor_sink<details::console_stderr, details
} // namespace sinks } // namespace sinks
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "ansicolor_sink-inl.h" #include "ansicolor_sink-inl.h"
#endif #endif

View File

@ -22,8 +22,7 @@ public:
explicit ostream_sink(std::ostream &os, bool force_flush = false) explicit ostream_sink(std::ostream &os, bool force_flush = false)
: ostream_(os) : ostream_(os)
, force_flush_(force_flush) , force_flush_(force_flush)
{ {}
}
ostream_sink(const ostream_sink &) = delete; ostream_sink(const ostream_sink &) = delete;
ostream_sink &operator=(const ostream_sink &) = delete; ostream_sink &operator=(const ostream_sink &) = delete;

View File

@ -8,13 +8,11 @@
SPDLOG_INLINE spdlog::sinks::sink::sink() SPDLOG_INLINE spdlog::sinks::sink::sink()
: formatter_{details::make_unique<spdlog::pattern_formatter>()} : formatter_{details::make_unique<spdlog::pattern_formatter>()}
{ {}
}
SPDLOG_INLINE spdlog::sinks::sink::sink(std::unique_ptr<spdlog::formatter> formatter) SPDLOG_INLINE spdlog::sinks::sink::sink(std::unique_ptr<spdlog::formatter> formatter)
: formatter_{std::move(formatter)} : formatter_{std::move(formatter)}
{ {}
}
SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const
{ {

View File

@ -38,6 +38,6 @@ protected:
} // namespace sinks } // namespace sinks
} // namespace spdlog } // namespace spdlog
#ifndef SPDLOG_STATIC_LIB #ifdef SPDLOG_HEADER_ONLY
#include "sink-inl.h" #include "sink-inl.h"
#endif #endif

View File

@ -26,8 +26,7 @@ public:
stdout_sink() stdout_sink()
: mutex_(ConsoleMutex::mutex()) : mutex_(ConsoleMutex::mutex())
, file_(TargetStream::stream()) , file_(TargetStream::stream())
{ {}
}
~stdout_sink() override = default; ~stdout_sink() override = default;
stdout_sink(const stdout_sink &other) = delete; stdout_sink(const stdout_sink &other) = delete;

View File

@ -1,65 +0,0 @@
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
// Slightly modified version of fmt lib to include bundled format-inl.h
#if !defined(SPDLOG_FMT_EXTERNAL)
#include "spdlog/fmt/bundled/format-inl.h"
#else
#include "fmt/format-inl.h"
#endif
FMT_BEGIN_NAMESPACE
template struct internal::basic_data<void>;
template FMT_API internal::locale_ref::locale_ref(const std::locale &loc);
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
// Explicit instantiations for char.
template FMT_API char internal::thousands_sep_impl(locale_ref);
template FMT_API void internal::basic_buffer<char>::append(const char *, const char *);
template FMT_API void internal::arg_map<format_context>::init(
const basic_format_args<format_context> &args);
template FMT_API int internal::char_traits<char>::format_float(
char *, std::size_t, const char *, int, double);
template FMT_API int internal::char_traits<char>::format_float(
char *, std::size_t, const char *, int, long double);
template FMT_API std::string internal::vformat<char>(
string_view, basic_format_args<format_context>);
template FMT_API format_context::iterator internal::vformat_to(
internal::buffer &, string_view, basic_format_args<format_context>);
template FMT_API void internal::sprintf_format(
double, internal::buffer &, core_format_specs);
template FMT_API void internal::sprintf_format(
long double, internal::buffer &, core_format_specs);
// Explicit instantiations for wchar_t.
template FMT_API wchar_t internal::thousands_sep_impl(locale_ref);
template FMT_API void internal::basic_buffer<wchar_t>::append(
const wchar_t *, const wchar_t *);
template FMT_API void internal::arg_map<wformat_context>::init(
const basic_format_args<wformat_context> &);
template FMT_API int internal::char_traits<wchar_t>::format_float(
wchar_t *, std::size_t, const wchar_t *, int, double);
template FMT_API int internal::char_traits<wchar_t>::format_float(
wchar_t *, std::size_t, const wchar_t *, int, long double);
template FMT_API std::wstring internal::vformat<wchar_t>(
wstring_view, basic_format_args<wformat_context>);
FMT_END_NAMESPACE

51
src/format.cpp Normal file
View File

@ -0,0 +1,51 @@
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
// Slightly modified version of fmt lib to include bundled format-inl.h
#if !defined(SPDLOG_FMT_EXTERNAL)
#include "spdlog/fmt/bundled/format-inl.h"
#else
#include "fmt/format-inl.h"
#endif
FMT_BEGIN_NAMESPACE
template struct internal::basic_data<void>;
template FMT_API internal::locale_ref::locale_ref(const std::locale &loc);
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
// Explicit instantiations for char.
template FMT_API char internal::thousands_sep_impl(locale_ref);
template FMT_API void internal::basic_buffer<char>::append(const char *, const char *);
template FMT_API void internal::arg_map<format_context>::init(const basic_format_args<format_context> &args);
template FMT_API int internal::char_traits<char>::format_float(char *, std::size_t, const char *, int, double);
template FMT_API int internal::char_traits<char>::format_float(char *, std::size_t, const char *, int, long double);
template FMT_API std::string internal::vformat<char>(string_view, basic_format_args<format_context>);
template FMT_API format_context::iterator internal::vformat_to(internal::buffer &, string_view, basic_format_args<format_context>);
template FMT_API void internal::sprintf_format(double, internal::buffer &, core_format_specs);
template FMT_API void internal::sprintf_format(long double, internal::buffer &, core_format_specs);
// Explicit instantiations for wchar_t.
template FMT_API wchar_t internal::thousands_sep_impl(locale_ref);
template FMT_API void internal::basic_buffer<wchar_t>::append(const wchar_t *, const wchar_t *);
template FMT_API void internal::arg_map<wformat_context>::init(const basic_format_args<wformat_context> &);
template FMT_API int internal::char_traits<wchar_t>::format_float(wchar_t *, std::size_t, const wchar_t *, int, double);
template FMT_API int internal::char_traits<wchar_t>::format_float(wchar_t *, std::size_t, const wchar_t *, int, long double);
template FMT_API std::wstring internal::vformat<wchar_t>(wstring_view, basic_format_args<wformat_context>);
FMT_END_NAMESPACE

View File

@ -2,11 +2,11 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT) // Distributed under the MIT License (http://opensource.org/licenses/MIT)
#include <mutex> #include <mutex>
#include <chrono>
#include "spdlog/common.h" #include "spdlog/common.h"
#include "spdlog/common-inl.h" #include "spdlog/common-inl.h"
#include "spdlog/details/null_mutex.h" #include "spdlog/details/null_mutex.h"
#include "spdlog/logger.h" #include "spdlog/logger.h"
@ -51,3 +51,8 @@ template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stdout, sp
template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stdout, spdlog::details::console_nullmutex>; template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stdout, spdlog::details::console_nullmutex>;
template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stderr, spdlog::details::console_mutex>; template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stderr, spdlog::details::console_mutex>;
template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stderr, spdlog::details::console_nullmutex>; template class spdlog::sinks::ansicolor_sink<spdlog::details::console_stderr, spdlog::details::console_nullmutex>;
// fmt_helper templates
#include "spdlog/details/fmt_helper.h"
template void spdlog::details::fmt_helper::append_string_view(spdlog::string_view_t view, fmt::memory_buffer &dest);
template spdlog::string_view_t spdlog::details::fmt_helper::to_string_view(const fmt::memory_buffer &buf) SPDLOG_NOEXCEPT;

View File

@ -39,8 +39,7 @@ TEST_CASE("default_error_handler", "[errors]]")
} }
struct custom_ex struct custom_ex
{ {};
};
TEST_CASE("custom_error_handler", "[errors]]") TEST_CASE("custom_error_handler", "[errors]]")
{ {
prepare_logdir(); prepare_logdir();