Simplify update logging.

This commit is contained in:
levlam 2022-12-11 01:20:13 +03:00
parent b10ad9ffc4
commit 1f129ecade

View File

@ -497,33 +497,29 @@ Status SessionConnection::on_slice_packet(const MsgInfo &info, Slice packet) {
return status; return status;
} }
auto get_update_description = [&] {
return PSTRING() << "update from " << get_name() << " active for " << (Time::now() - created_at_)
<< " seconds in container " << container_id_ << " from session " << auth_data_->get_session_id()
<< " with message_id " << info.message_id << ", main_message_id = " << main_message_id_
<< ", seq_no = " << info.seq_no << " and original size = " << info.size;
};
// It is an update... I hope. // It is an update... I hope.
status = auth_data_->check_update(info.message_id); status = auth_data_->check_update(info.message_id);
auto recheck_status = auth_data_->recheck_update(info.message_id); auto recheck_status = auth_data_->recheck_update(info.message_id);
if (recheck_status.is_error() && recheck_status.code() == 2) { if (recheck_status.is_error() && recheck_status.code() == 2) {
LOG(WARNING) << "Receive very old update from " << get_name() << " created in " << (Time::now() - created_at_) LOG(WARNING) << "Receive very old " << get_update_description() << ": " << status << ' ' << recheck_status;
<< " in container " << container_id_ << " from session " << auth_data_->get_session_id()
<< " with message_id " << info.message_id << ", main_message_id = " << main_message_id_
<< ", seq_no = " << info.seq_no << " and original size " << info.size << ": " << status << ' '
<< recheck_status;
} }
if (status.is_error()) { if (status.is_error()) {
if (status.code() == 2) { if (status.code() == 2) {
LOG(WARNING) << "Receive too old update from " << get_name() << " created in " << (Time::now() - created_at_) LOG(WARNING) << "Receive too old " << get_update_description() << ": " << status;
<< " in container " << container_id_ << " from session " << auth_data_->get_session_id()
<< " with message_id " << info.message_id << ", main_message_id = " << main_message_id_
<< ", seq_no = " << info.seq_no << " and original size " << info.size << ": " << status;
callback_->on_session_failed(Status::Error("Receive too old update")); callback_->on_session_failed(Status::Error("Receive too old update"));
return status; return status;
} }
VLOG(mtproto) << "Skip update " << info.message_id << " of size " << info.size << " with seq_no " << info.seq_no VLOG(mtproto) << "Skip " << get_update_description() << ": " << status;
<< " from " << get_name() << " created in " << (Time::now() - created_at_) << ": " << status;
return Status::OK(); return Status::OK();
} else { } else {
VLOG(mtproto) << "Got update from " << get_name() << " created in " << (Time::now() - created_at_) VLOG(mtproto) << "Receive " << get_update_description();
<< " in container " << container_id_ << " from session " << auth_data_->get_session_id()
<< " with message_id " << info.message_id << ", main_message_id = " << main_message_id_
<< ", seq_no = " << info.seq_no << " and original size " << info.size;
return callback_->on_update(as_buffer_slice(packet)); return callback_->on_update(as_buffer_slice(packet));
} }
} }