This commit is contained in:
Denis Ivaykin 2015-05-08 22:57:52 +02:00
parent 06e0b0387a
commit 849b5cb84e
5 changed files with 21 additions and 0 deletions

View File

@ -87,6 +87,10 @@ public:
} }
void flush() {
std::fflush(_fd);
}
void close() void close()
{ {
if (_fd) if (_fd)

View File

@ -58,6 +58,7 @@ public:
_sink_it(msg); _sink_it(msg);
} }
virtual void flush() = 0;
protected: protected:
virtual void _sink_it(const details::log_msg& msg) = 0; virtual void _sink_it(const details::log_msg& msg) = 0;

View File

@ -80,6 +80,10 @@ public:
_file_helper.open(calc_filename(_base_filename, 0, _extension)); _file_helper.open(calc_filename(_base_filename, 0, _extension));
} }
virtual void flush() override {
_file_helper.flush();
}
protected: protected:
void _sink_it(const details::log_msg& msg) override void _sink_it(const details::log_msg& msg) override
{ {
@ -167,6 +171,10 @@ public:
_file_helper.open(calc_filename(_base_filename, _extension)); _file_helper.open(calc_filename(_base_filename, _extension));
} }
virtual void flush() override {
_file_helper.flush();
}
protected: protected:
void _sink_it(const details::log_msg& msg) override void _sink_it(const details::log_msg& msg) override
{ {

View File

@ -40,6 +40,9 @@ protected:
void _sink_it(const details::log_msg&) override void _sink_it(const details::log_msg&) override
{} {}
void flush() override
{}
}; };
typedef null_sink<details::null_mutex> null_sink_st; typedef null_sink<details::null_mutex> null_sink_st;
typedef null_sink<std::mutex> null_sink_mt; typedef null_sink<std::mutex> null_sink_mt;

View File

@ -51,6 +51,11 @@ protected:
if (_force_flush) if (_force_flush)
_ostream.flush(); _ostream.flush();
} }
virtual void flush() override {
_ostream.flush();
}
std::ostream& _ostream; std::ostream& _ostream;
bool _force_flush; bool _force_flush;
}; };