mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
Refactored sink interface and base_sink
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
template<class It>
|
||||
template<typename It>
|
||||
inline spdlog::async_logger::async_logger(const std::string &logger_name, const It &begin, const It &end,
|
||||
std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy)
|
||||
: logger(logger_name, begin, end)
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
//
|
||||
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
#include "stdio.h"
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
struct console_stdout_stream
|
||||
struct console_stdout
|
||||
{
|
||||
static FILE *stream()
|
||||
{
|
||||
@@ -21,7 +25,7 @@ struct console_stdout_stream
|
||||
#endif
|
||||
};
|
||||
|
||||
struct console_stderr_stream
|
||||
struct console_stderr
|
||||
{
|
||||
static FILE *stream()
|
||||
{
|
||||
@@ -35,23 +39,23 @@ struct console_stderr_stream
|
||||
#endif
|
||||
};
|
||||
|
||||
struct console_global_mutex
|
||||
struct console_mutex
|
||||
{
|
||||
using mutex_t = std::mutex;
|
||||
static mutex_t &console_mutex()
|
||||
static mutex_t &mutex()
|
||||
{
|
||||
static mutex_t mutex;
|
||||
return mutex;
|
||||
static mutex_t s_mutex;
|
||||
return s_mutex;
|
||||
}
|
||||
};
|
||||
|
||||
struct console_global_nullmutex
|
||||
struct console_nullmutex
|
||||
{
|
||||
using mutex_t = null_mutex;
|
||||
static mutex_t &console_mutex()
|
||||
static mutex_t &mutex()
|
||||
{
|
||||
static mutex_t mutex;
|
||||
return mutex;
|
||||
static mutex_t s_mutex;
|
||||
return s_mutex;
|
||||
}
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// create logger with given name, sinks and the default pattern formatter
|
||||
// all other ctors will call this one
|
||||
template<class It>
|
||||
template<typename It>
|
||||
inline spdlog::logger::logger(std::string logger_name, const It &begin, const It &end)
|
||||
: name_(std::move(logger_name))
|
||||
, sinks_(begin, end)
|
||||
@@ -36,7 +36,7 @@ inline spdlog::logger::logger(const std::string &logger_name, spdlog::sink_ptr s
|
||||
|
||||
inline spdlog::logger::~logger() = default;
|
||||
|
||||
template<class FormatterT, typename... Args>
|
||||
template<typename FormatterT, typename... Args>
|
||||
inline void spdlog::logger::set_formatter(const Args &... args)
|
||||
{
|
||||
for (auto &sink : sinks_)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace spdlog {
|
||||
namespace details {
|
||||
class thread_pool;
|
||||
|
||||
template<class Mutex>
|
||||
template<typename Mutex>
|
||||
class registry_t
|
||||
{
|
||||
public:
|
||||
@@ -46,8 +46,7 @@ public:
|
||||
auto logger_name = new_logger->name();
|
||||
throw_if_exists_(logger_name);
|
||||
|
||||
// create default formatter if not exists
|
||||
|
||||
// set the global formatter pattern
|
||||
new_logger->set_formatter<pattern_formatter>(formatter_pattern_, pattern_time_type_);
|
||||
|
||||
if (err_handler_)
|
||||
|
||||
Reference in New Issue
Block a user