4 #include "util/asio/glog_asio_sink.h" 5 #include <glog/raw_logging.h> 8 using namespace ::boost;
11 using namespace fibers;
13 GlogAsioSink::GlogAsioSink() : msg_q_(64) {
16 GlogAsioSink::~GlogAsioSink() noexcept {
19 void GlogAsioSink::Run() {
20 google::AddLogSink(
this);
21 RAW_DLOG(INFO,
"Started running");
22 run_started_.store(
true, std::memory_order_seq_cst);
27 channel_op_status st = msg_q_.pop(item);
28 if (st == channel_op_status::closed)
31 CHECK_EQ(channel_op_status::success, st);
36 LOG_IF(INFO, lost_messages_ > 0) <<
"GlogAsioSink lost " << lost_messages_ <<
" lost messages ";
39 void GlogAsioSink::Cancel() {
40 google::RemoveLogSink(
this);
44 void GlogAsioSink::WaitTillRun() {
45 ec_.await([
this] {
return run_started_.load(std::memory_order_acquire); });
48 void GlogAsioSink::send(google::LogSeverity severity,
const char* full_filename,
49 const char* base_filename,
int line,
const struct ::tm* tm_time,
50 const char* message,
size_t message_len) {
51 if (ShouldIgnore(severity, full_filename, line))
55 channel_op_status st = msg_q_.push_wait_for(
56 Item{full_filename, base_filename, severity, line, *tm_time,
string{message, message_len}},
59 if (st != channel_op_status::success) {
62 RAW_VLOG(1,
"GlogAsioSink::SendExit : %d",
int(st));
65 void GlogAsioSink::WaitTillSent() {