From e58e8d3989e7f2fa3dbe0c6019ad0ee9658a769b Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 8 Sep 2023 18:09:08 +0300 Subject: [PATCH] Improve query logging. --- telegram-bot-api/Query.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telegram-bot-api/Query.cpp b/telegram-bot-api/Query.cpp index cf7d377..39a59da 100644 --- a/telegram-bot-api/Query.cpp +++ b/telegram-bot-api/Query.cpp @@ -43,7 +43,7 @@ Query::Query(td::vector &&container, td::Slice token, bool is_t } td::to_lower_inplace(method_); start_timestamp_ = td::Time::now(); - LOG(INFO) << "QUERY: create " << td::tag("ptr", this) << *this; + LOG(INFO) << "Query " << this << ": " << *this; if (shared_data_) { shared_data_->query_count_.fetch_add(1, std::memory_order_relaxed); if (method_ != "getupdates") { @@ -85,7 +85,7 @@ void Query::set_stat_actor(td::ActorId stat_actor) { void Query::set_ok(td::BufferSlice result) { CHECK(state_ == State::Query); - LOG(INFO) << "QUERY: got ok " << td::tag("ptr", this) << td::tag("text", result.as_slice()); + LOG(INFO) << "Query " << this << ": " << td::tag("method", method_) << td::tag("text", result.as_slice()); answer_ = std::move(result); state_ = State::OK; http_status_code_ = 200; @@ -93,7 +93,7 @@ void Query::set_ok(td::BufferSlice result) { } void Query::set_error(int http_status_code, td::BufferSlice result) { - LOG(INFO) << "QUERY: got error " << td::tag("ptr", this) << td::tag("code", http_status_code) + LOG(INFO) << "Query " << this << ": " << td::tag("method", method_) << td::tag("code", http_status_code) << td::tag("text", result.as_slice()); CHECK(state_ == State::Query); answer_ = std::move(result); @@ -115,7 +115,7 @@ td::StringBuilder &operator<<(td::StringBuilder &sb, const Query &query) { auto padded_time = td::lpad(PSTRING() << td::format::as_time(td::Time::now_cached() - query.start_timestamp()), 10, ' '); sb << "[bot" << td::rpad(query.token().str(), 46, ' ') << "][time:" << padded_time << ']' - << td::tag("method", td::lpad(query.method().str(), 20, ' ')); + << td::tag("method", td::lpad(query.method().str(), 25, ' ')); if (!query.args().empty()) { sb << '{'; for (const auto &arg : query.args()) {