mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 03:19:02 +08:00
Renamed simple_file_sink -> basic_file_sink
This commit is contained in:
@@ -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};
|
||||
|
Reference in New Issue
Block a user