mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-01 10:59:02 +08:00
bench
This commit is contained in:
@@ -33,6 +33,9 @@ public:
|
||||
//Wait to remaining items (if any) in the queue to be written and shutdown
|
||||
void shutdown(const std::chrono::milliseconds& timeout);
|
||||
|
||||
void close() override;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override;
|
||||
@@ -123,6 +126,11 @@ inline void spdlog::sinks::async_sink::shutdown(const std::chrono::milliseconds&
|
||||
_shutdown();
|
||||
}
|
||||
|
||||
inline void spdlog::sinks::async_sink::close()
|
||||
{
|
||||
_shutdown();
|
||||
}
|
||||
|
||||
|
||||
inline void spdlog::sinks::async_sink::_shutdown()
|
||||
{
|
||||
@@ -133,5 +141,8 @@ inline void spdlog::sinks::async_sink::_shutdown()
|
||||
if (_back_thread.joinable())
|
||||
_back_thread.join();
|
||||
}
|
||||
|
||||
for (auto &s : _sinks)
|
||||
s->close();
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,10 @@ public:
|
||||
{
|
||||
_file_helper.open(filename);
|
||||
}
|
||||
void close() override
|
||||
{
|
||||
_file_helper.close();
|
||||
}
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
@@ -60,6 +64,11 @@ public:
|
||||
_file_helper.open(calc_filename(_base_filename, 0, _extension));
|
||||
}
|
||||
|
||||
void close() override
|
||||
{
|
||||
_file_helper.close();
|
||||
}
|
||||
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
@@ -140,6 +149,11 @@ public:
|
||||
_file_helper.open(calc_filename(_base_filename, _extension));
|
||||
}
|
||||
|
||||
void close() override
|
||||
{
|
||||
_file_helper.close();
|
||||
}
|
||||
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
|
@@ -13,6 +13,9 @@ class null_sink : public base_sink<Mutex>
|
||||
protected:
|
||||
void _sink_it(const details::log_msg&) override
|
||||
{}
|
||||
|
||||
void close() override
|
||||
{}
|
||||
};
|
||||
|
||||
typedef null_sink<details::null_mutex> null_sink_st;
|
||||
|
@@ -21,6 +21,9 @@ public:
|
||||
virtual ~ostream_sink() = default;
|
||||
|
||||
|
||||
void close() override
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
|
@@ -11,6 +11,7 @@ class sink
|
||||
public:
|
||||
virtual ~sink() {}
|
||||
virtual void log(const details::log_msg& msg) = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ class stdout_sink : public ostream_sink<Mutex>
|
||||
{
|
||||
public:
|
||||
stdout_sink() : ostream_sink<Mutex>(std::cout) {}
|
||||
|
||||
};
|
||||
|
||||
typedef stdout_sink<details::null_mutex> stdout_sink_st;
|
||||
|
Reference in New Issue
Block a user