mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-29 08:56:18 +02:00
string replaced with stream
This commit is contained in:
parent
0cc2c39357
commit
d51cb125fc
2 changed files with 11 additions and 9 deletions
|
@ -44,24 +44,25 @@ std::string Log::Timestamp()
|
|||
|
||||
int Log::sync()
|
||||
{
|
||||
if (buffer_.length())
|
||||
if (buffer_.str().length())
|
||||
{
|
||||
if (priority_ == kDbg)
|
||||
#ifdef DEBUG_LOG
|
||||
std::cout << Timestamp() << " [dbg] " << buffer_.c_str() << std::flush;
|
||||
std::cout << Timestamp() << " [dbg] " << buffer_.str() << std::flush;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
else if (priority_ == kOut)
|
||||
std::cout << Timestamp() << " [out] " << buffer_.c_str() << std::flush;
|
||||
std::cout << Timestamp() << " [out] " << buffer_.str() << std::flush;
|
||||
else if (priority_ == kErr)
|
||||
std::cout << Timestamp() << " [err] " << buffer_.c_str() << std::flush;
|
||||
std::cout << Timestamp() << " [err] " << buffer_.str() << std::flush;
|
||||
else
|
||||
{
|
||||
std::cout << Timestamp() << " [" << std::to_string(priority_) << "] " << buffer_.c_str() << std::flush;
|
||||
syslog(priority_, "%s", buffer_.c_str());
|
||||
std::cout << Timestamp() << " [" << std::to_string(priority_) << "] " << buffer_.str() << std::flush;
|
||||
syslog(priority_, "%s", buffer_.str().c_str());
|
||||
}
|
||||
buffer_.erase();
|
||||
buffer_.str("");
|
||||
buffer_.clear();
|
||||
priority_ = kLogDebug; // default to debug for each message
|
||||
}
|
||||
return 0;
|
||||
|
@ -72,7 +73,7 @@ int Log::overflow(int c)
|
|||
{
|
||||
if (c != EOF)
|
||||
{
|
||||
buffer_ += static_cast<char>(c);
|
||||
buffer_ << static_cast<char>(c);
|
||||
if (c == '\n')
|
||||
sync();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue