mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
Renamed simple_file_sink -> basic_file_sink
This commit is contained in:
@@ -23,7 +23,7 @@ namespace spdlog {
|
||||
|
||||
// async logger factory - creates async loggers backed with thread pool.
|
||||
// if a global thread pool doesn't already exist, create it with default queue size of 8192 items and single thread.
|
||||
struct create_async
|
||||
struct async_factory
|
||||
{
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
static std::shared_ptr<async_logger> create(const std::string &logger_name, SinkArgs &&... args)
|
||||
@@ -46,9 +46,9 @@ struct create_async
|
||||
};
|
||||
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
inline std::shared_ptr<spdlog::logger> create_async_logger(const std::string &logger_name, SinkArgs &&... sink_args)
|
||||
inline std::shared_ptr<spdlog::logger> create_async(const std::string &logger_name, SinkArgs &&... sink_args)
|
||||
{
|
||||
return create_async::create<Sink>(logger_name, std::forward<SinkArgs>(sink_args)...);
|
||||
return async_factory::create<Sink>(logger_name, std::forward<SinkArgs>(sink_args)...);
|
||||
}
|
||||
|
||||
// set global thread pool.
|
||||
|
@@ -6,8 +6,8 @@
|
||||
#pragma once
|
||||
//
|
||||
// base sink templated over a mutex (either dummy or real)
|
||||
// concrete implementation should only override the sink_it_ method.
|
||||
// all locking is taken care of here so no locking needed by the implementers..
|
||||
// concrete implementation should override the sink_it_() and flush_() methods.
|
||||
// locking is taken care of in this class - no locking needed by the implementers..
|
||||
//
|
||||
|
||||
#include "spdlog/common.h"
|
||||
@@ -26,16 +26,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
base_sink(const std::string &formatter_pattern)
|
||||
: sink(formatter_pattern)
|
||||
{
|
||||
}
|
||||
|
||||
base_sink(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||||
: sink(std::move(sink_formatter))
|
||||
{
|
||||
}
|
||||
|
||||
base_sink(const base_sink &) = delete;
|
||||
base_sink &operator=(const base_sink &) = delete;
|
||||
|
||||
|
@@ -18,10 +18,10 @@ namespace sinks {
|
||||
* Trivial file sink with single file as target
|
||||
*/
|
||||
template<class Mutex>
|
||||
class simple_file_sink SPDLOG_FINAL : public base_sink<Mutex>
|
||||
class basic_file_sink SPDLOG_FINAL : public base_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
explicit simple_file_sink(const filename_t &filename, bool truncate = false)
|
||||
explicit basic_file_sink(const filename_t &filename, bool truncate = false)
|
||||
{
|
||||
file_helper_.open(filename, truncate);
|
||||
}
|
||||
@@ -43,8 +43,8 @@ private:
|
||||
details::file_helper file_helper_;
|
||||
};
|
||||
|
||||
using simple_file_sink_mt = simple_file_sink<std::mutex>;
|
||||
using simple_file_sink_st = simple_file_sink<details::null_mutex>;
|
||||
using basic_file_sink_mt = basic_file_sink<std::mutex>;
|
||||
using basic_file_sink_st = basic_file_sink<details::null_mutex>;
|
||||
|
||||
} // namespace sinks
|
||||
|
||||
@@ -54,13 +54,13 @@ using simple_file_sink_st = simple_file_sink<details::null_mutex>;
|
||||
template<typename Factory = default_factory>
|
||||
inline std::shared_ptr<logger> basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false)
|
||||
{
|
||||
return Factory::template create<sinks::simple_file_sink_mt>(logger_name, filename, truncate);
|
||||
return Factory::template create<sinks::basic_file_sink_mt>(logger_name, filename, truncate);
|
||||
}
|
||||
|
||||
template<typename Factory = default_factory>
|
||||
inline std::shared_ptr<logger> basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false)
|
||||
{
|
||||
return Factory::template create<sinks::simple_file_sink_st>(logger_name, filename, truncate);
|
||||
return Factory::template create<sinks::basic_file_sink_st>(logger_name, filename, truncate);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
@@ -18,17 +18,17 @@ public:
|
||||
: formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter("%+")))
|
||||
{
|
||||
}
|
||||
|
||||
explicit sink(const std::string &formatter_pattern)
|
||||
: formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
|
||||
{
|
||||
}
|
||||
|
||||
// sink with custom formatter
|
||||
explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||||
: formatter_(std::move(sink_formatter))
|
||||
{
|
||||
}
|
||||
//
|
||||
// explicit sink(const std::string &formatter_pattern)
|
||||
// : formatter_(std::unique_ptr<spdlog::formatter>(new pattern_formatter(formatter_pattern)))
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// // sink with custom formatter
|
||||
// explicit sink(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||||
// : formatter_(std::move(sink_formatter))
|
||||
// {
|
||||
// }
|
||||
|
||||
virtual ~sink() = default;
|
||||
|
||||
@@ -39,10 +39,12 @@ public:
|
||||
{
|
||||
return msg_level >= level_.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void set_level(level::level_enum log_level)
|
||||
{
|
||||
level_.store(log_level);
|
||||
}
|
||||
|
||||
level::level_enum level() const
|
||||
{
|
||||
return static_cast<spdlog::level::level_enum>(level_.load(std::memory_order_relaxed));
|
||||
@@ -58,10 +60,6 @@ public:
|
||||
formatter_ = std::move(sink_formatter);
|
||||
}
|
||||
|
||||
spdlog::formatter *formatter()
|
||||
{
|
||||
return formatter_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
level_t level_{level::trace};
|
||||
|
@@ -19,7 +19,7 @@
|
||||
namespace spdlog {
|
||||
|
||||
// Default logger factory- creates synchronous loggers
|
||||
struct create_synchronous
|
||||
struct synchronous_factory
|
||||
{
|
||||
template<typename Sink, typename... SinkArgs>
|
||||
|
||||
@@ -32,7 +32,7 @@ struct create_synchronous
|
||||
}
|
||||
};
|
||||
|
||||
using default_factory = create_synchronous;
|
||||
using default_factory = synchronous_factory;
|
||||
|
||||
// Create and register a logger with a templated sink type
|
||||
// The logger's level, formatter and flush level will be set according the global settings.
|
||||
|
Reference in New Issue
Block a user