31 int dccl::internal::LogBuffer::sync()
33 #if DCCL_THREAD_SUPPORT
34 if (verbosity() == logger::UNKNOWN)
37 <<
"Must use 'dlog.is(...) && dlog << ... << std::endl;' expression when running in "
38 "thread safe mode to allow the dlog mutex to be correctly locked and unlocked. "
40 << buffer_.front() << std::endl;
47 while (buffer_.size() > 1)
49 display(buffer_.front());
53 if (!verbosity_.empty())
58 #if DCCL_THREAD_SUPPORT
59 g_dlog_mutex.unlock();
64 int dccl::internal::LogBuffer::overflow(
int c)
72 buffer_.emplace_back();
76 buffer_.back().push_back(c);
81 void dccl::to_ostream(
const std::string& msg, dccl::logger::Verbosity ,
82 dccl::logger::Group grp, std::ostream* os,
bool add_timestamp)
88 case logger::GENERAL:
break;
89 case logger::ENCODE: grp_str =
"{encode}: ";
break;
90 case logger::DECODE: grp_str =
"{decode}: ";
break;
91 case logger::SIZE: grp_str =
"{size}: ";
break;
94 std::time_t now = std::time(
nullptr);
95 std::tm* t = std::gmtime(&now);
99 *os <<
"[ " << (t->tm_year + 1900) <<
"-" << std::setw(2) << std::setfill(
'0')
100 << (t->tm_mon + 1) <<
"-" << std::setw(2) << t->tm_mday <<
" " << std::setw(2)
101 << t->tm_hour <<
":" << std::setw(2) << t->tm_min <<
":" << std::setw(2) << t->tm_sec
102 <<
" ]: " << std::setfill(
' ');
105 *os << grp_str << msg << std::endl;