This commit is contained in:
gabi
2014-11-01 02:12:12 +02:00
parent bf303fad19
commit 567e85e6d4
15 changed files with 169 additions and 89 deletions

View File

@@ -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();
}

View File

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

View File

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

View File

@@ -21,6 +21,9 @@ public:
virtual ~ostream_sink() = default;
void close() override
{}
protected:
virtual void _sink_it(const details::log_msg& msg) override
{

View File

@@ -11,6 +11,7 @@ class sink
public:
virtual ~sink() {}
virtual void log(const details::log_msg& msg) = 0;
virtual void close() = 0;
};
}
}

View File

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