From 4f9887b4bdeb78dfcd547e9de4fbd354ccdb63e2 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 13 May 2019 19:34:23 +0300 Subject: [PATCH] Minor logging impprovements. GitOrigin-RevId: 54f2abbd0be6d3ee5cd88ac75f14a660c0201359 --- td/mtproto/SessionConnection.cpp | 2 +- td/mtproto/Transport.cpp | 19 ++++++++++--------- td/telegram/SecretChatActor.cpp | 8 ++++---- td/telegram/net/Session.cpp | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 8a2de229..4f319851 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -433,7 +433,7 @@ Status SessionConnection::on_packet(const MsgInfo &info, const mtproto_api::futu Status SessionConnection::on_msgs_state_info(const std::vector &ids, Slice info) { if (ids.size() != info.size()) { - return Status::Error(PSLICE() << tag("ids.size()", ids.size()) << "!=" << tag("info.size()", info.size())); + return Status::Error(PSLICE() << tag("ids.size()", ids.size()) << " != " << tag("info.size()", info.size())); } size_t i = 0; for (auto id : ids) { diff --git a/td/mtproto/Transport.cpp b/td/mtproto/Transport.cpp index 60995274..d56d71af 100644 --- a/td/mtproto/Transport.cpp +++ b/td/mtproto/Transport.cpp @@ -180,7 +180,7 @@ size_t Transport::calc_no_crypto_size(size_t data_size) { Status Transport::read_no_crypto(MutableSlice message, PacketInfo *info, MutableSlice *data) { if (message.size() < sizeof(NoCryptoHeader)) { - return Status::Error(PSLICE() << "Invalid mtproto message: too small [message.size()=" << message.size() + return Status::Error(PSLICE() << "Invalid mtproto message: too small [message.size() = " << message.size() << "] < [sizeof(NoCryptoHeader) = " << sizeof(NoCryptoHeader) << "]"); } size_t data_size = message.size() - sizeof(NoCryptoHeader); @@ -193,7 +193,7 @@ template Status Transport::read_crypto_impl(int X, MutableSlice message, const AuthKey &auth_key, HeaderT **header_ptr, PrefixT **prefix_ptr, MutableSlice *data, PacketInfo *info) { if (message.size() < sizeof(HeaderT)) { - return Status::Error(PSLICE() << "Invalid mtproto message: too small [message.size()=" << message.size() + return Status::Error(PSLICE() << "Invalid mtproto message: too small [message.size() = " << message.size() << "] < [sizeof(HeaderT) = " << sizeof(HeaderT) << "]"); } //FIXME: rewrite without reinterpret cast @@ -202,14 +202,14 @@ Status Transport::read_crypto_impl(int X, MutableSlice message, const AuthKey &a auto to_decrypt = MutableSlice(header->encrypt_begin(), message.uend()); to_decrypt = to_decrypt.truncate(to_decrypt.size() & ~15); if (to_decrypt.size() % 16 != 0) { - return Status::Error(PSLICE() << "Invalid mtproto message: size of encrypted part is not multiple of 16 [size=" + return Status::Error(PSLICE() << "Invalid mtproto message: size of encrypted part is not multiple of 16 [size = " << to_decrypt.size() << "]"); } if (header->auth_key_id != auth_key.id()) { - return Status::Error(PSLICE() << "Invalid mtproto message: auth_key_id mismatch [found=" + return Status::Error(PSLICE() << "Invalid mtproto message: auth_key_id mismatch [found = " << format::as_hex(header->auth_key_id) - << "] [expected=" << format::as_hex(auth_key.id()) << "]"); + << "] [expected = " << format::as_hex(auth_key.id()) << "]"); } UInt256 aes_key; @@ -249,9 +249,9 @@ Status Transport::read_crypto_impl(int X, MutableSlice message, const AuthKey &a } if (!is_key_ok) { - return Status::Error(PSLICE() << "Invalid mtproto message: message_key mismatch [found=" + return Status::Error(PSLICE() << "Invalid mtproto message: message_key mismatch [found = " << format::as_hex_dump(header->message_key) - << "] [expected=" << format::as_hex_dump(real_message_key) << "]"); + << "] [expected = " << format::as_hex_dump(real_message_key) << "]"); } if (info->version == 2) { @@ -405,7 +405,7 @@ size_t Transport::write_e2e_crypto(const Storer &storer, const AuthKey &auth_key Result Transport::read_auth_key_id(Slice message) { if (message.size() < 8) { - return Status::Error(PSLICE() << "Invalid mtproto message: smaller than 8 bytes [size=" << message.size() << "]"); + return Status::Error(PSLICE() << "Invalid mtproto message: smaller than 8 bytes [size = " << message.size() << "]"); } return as(message.begin()); } @@ -413,7 +413,8 @@ Result Transport::read_auth_key_id(Slice message) { Result Transport::read(MutableSlice message, const AuthKey &auth_key, PacketInfo *info) { if (message.size() < 12) { if (message.size() < 4) { - return Status::Error(PSLICE() << "Invalid mtproto message: smaller than 4 bytes [size=" << message.size() << "]"); + return Status::Error(PSLICE() << "Invalid mtproto message: smaller than 4 bytes [size = " << message.size() + << "]"); } int32 code = as(message.begin()); diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index d3b1e1ca..27c5bafe 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -496,8 +496,8 @@ void SecretChatActor::send_action(tl_object_ptrsecond.get_list_node()); if (!status.second) { - LOG(FATAL) << "Duplicate message_id oO [message_id=" << message_id << "]"; + LOG(FATAL) << "Duplicate message_id [message_id = " << message_id << "]"; } }