mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
Simplified sink interface - to just accept char* and size_t
This commit is contained in:
@@ -82,10 +82,10 @@ public:
|
||||
|
||||
void reopen()
|
||||
{
|
||||
if(_filename.empty())
|
||||
throw spdlog_ex("Failed re opening file - was not opened before");
|
||||
open(_filename);
|
||||
|
||||
if(_filename.empty())
|
||||
throw spdlog_ex("Failed re opening file - was not opened before");
|
||||
open(_filename);
|
||||
|
||||
}
|
||||
|
||||
void close()
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void write(const log_msg& msg)
|
||||
void write(const char* data, size_t size)
|
||||
{
|
||||
auto& buf = msg.formatted.buf();
|
||||
size_t size = buf.size();
|
||||
if(std::fwrite(buf.data(), sizeof(char), size, _fd) != size)
|
||||
|
||||
|
||||
if(std::fwrite(data, sizeof(char), size, _fd) != size)
|
||||
throw spdlog_ex("Failed writing to file " + _filename);
|
||||
|
||||
if(--_flush_countdown == 0)
|
||||
|
||||
@@ -184,7 +184,8 @@ inline void spdlog::logger::_variadic_log(spdlog::details::line_logger& l, const
|
||||
inline void spdlog::logger::_log_msg(details::log_msg& msg)
|
||||
{
|
||||
_formatter->format(msg);
|
||||
auto buf = msg.formatted.buf();
|
||||
for (auto &sink : _sinks)
|
||||
sink->log(msg);
|
||||
sink->sink_it(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user