mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
minor fixes in fast_oss
This commit is contained in:
parent
4ed60befbc
commit
8b53671c06
@ -12,6 +12,7 @@ namespace details
|
|||||||
class str_devicebuf:public std::streambuf
|
class str_devicebuf:public std::streambuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using Base = std::streambuf;
|
||||||
str_devicebuf() = default;
|
str_devicebuf() = default;
|
||||||
~str_devicebuf() = default;
|
~str_devicebuf() = default;
|
||||||
|
|
||||||
@ -31,13 +32,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int sync() override
|
// copy the give buffer into the accumulated fast buffer
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy the give buffer into the accumulated string.
|
|
||||||
// reserve initially 128 bytes which should be enough for common log lines
|
|
||||||
std::streamsize xsputn(const char_type* s, std::streamsize count) override
|
std::streamsize xsputn(const char_type* s, std::streamsize count) override
|
||||||
{
|
{
|
||||||
_fastbuf.append(s, static_cast<unsigned int>(count));
|
_fastbuf.append(s, static_cast<unsigned int>(count));
|
||||||
@ -46,13 +41,12 @@ protected:
|
|||||||
|
|
||||||
int_type overflow(int_type ch) override
|
int_type overflow(int_type ch) override
|
||||||
{
|
{
|
||||||
bool not_eofile = traits_type::not_eof(ch);
|
if (traits_type::not_eof(ch))
|
||||||
if (not_eofile)
|
|
||||||
{
|
{
|
||||||
char c = traits_type::to_char_type(ch);
|
char c = traits_type::to_char_type(ch);
|
||||||
xsputn(&c, 1);
|
xsputn(&c, 1);
|
||||||
}
|
}
|
||||||
return not_eofile;
|
return ch;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
fast_buf<192> _fastbuf;
|
fast_buf<192> _fastbuf;
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (_enabled)
|
if (_enabled)
|
||||||
_oss << msg;
|
_oss << msg;
|
||||||
|
|
||||||
return std::move(*this);
|
return std::move(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user