Refactored sink interface and base_sink

This commit is contained in:
gabime
2018-07-14 16:21:53 +03:00
parent 2bc05b6b17
commit c2a49080aa
25 changed files with 200 additions and 120 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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_)

View File

@@ -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_)