add logging cats

This commit is contained in:
2023-01-04 20:25:41 +01:00
parent d4f3d3c4fb
commit 6852cdd046
3 changed files with 40 additions and 40 deletions

View File

@@ -26,7 +26,7 @@ void NGC_HS1::Peer::append(uint32_t msg_id, Tox_Message_Type type, const std::st
heard_of.erase(msg_id);
}
fprintf(stderr, "######## last msgs ########\n");
fprintf(stderr, "HS: ######## last msgs ########\n");
auto rit = order.crbegin();
for (size_t i = 0; i < 10 && rit != order.crend(); i++, rit++) {
fprintf(stderr, " %08X - %s\n", *rit, dict.at(*rit).text.c_str());
@@ -126,7 +126,7 @@ static void _iterate_group(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_nu
}
if (ngc_hs1_ctx->history.count(g_id) == 0) {
fprintf(stderr, "adding new group: %u %X%X%X%X\n",
fprintf(stderr, "HS: adding new group: %u %X%X%X%X\n",
group_number,
g_id.data.data()[0],
g_id.data.data()[1],
@@ -144,7 +144,7 @@ static void _iterate_group(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_nu
if (peer.time_since_last_request_sent > ngc_hs1_ctx->options.query_interval_per_peer) {
peer.time_since_last_request_sent = 0.f;
fprintf(stderr, "requesting ids for %X%X%X%X\n", peer_key.data.data()[0], peer_key.data.data()[1], peer_key.data.data()[2], peer_key.data.data()[3]);
fprintf(stderr, "HS: requesting ids for %X%X%X%X\n", peer_key.data.data()[0], peer_key.data.data()[1], peer_key.data.data()[2], peer_key.data.data()[3]);
// TODO: other way around?
// ask everyone if they have newer stuff for this peer
@@ -165,7 +165,7 @@ static void _iterate_group(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_nu
it->second.time_since_ft_activity += time_delta;
if (it->second.time_since_ft_activity >= ngc_hs1_ctx->options.ft_activity_timeout) {
// timed out
fprintf(stderr, "!!! pending ft request timed out (%08X)\n", it->first);
fprintf(stderr, "HS: !!! pending ft request timed out (%08X)\n", it->first);
it = peer.pending.erase(it);
} else {
it++;
@@ -185,7 +185,7 @@ static void _iterate_group(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_nu
}
if (remote_peer_numbers.empty()) {
fprintf(stderr, "!!! msg_id we heard of, but no remote peer !!!\n");
fprintf(stderr, "HS: !!! msg_id we heard of, but no remote peer !!!\n");
continue;
}
@@ -241,7 +241,7 @@ void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/) {
// safety
if (g_i > group_count + 1000) {
fprintf(stderr, "WAY PAST GOUPS in iterate\n");
fprintf(stderr, "HS: WAY PAST GOUPS in iterate\n");
break;
}
}
@@ -312,7 +312,7 @@ void NGC_HS1_record_own_message(
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
) {
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
fprintf(stderr, "record_own_message %08X\n", message_id);
fprintf(stderr, "HS: record_own_message %08X\n", message_id);
// get group id
_GroupKey g_id{};
{ // TODO: error
@@ -345,7 +345,7 @@ void NGC_HS1_record_message(
return;
}
fprintf(stderr, "record_message %08X\n", message_id);
fprintf(stderr, "HS: record_message %08X\n", message_id);
// get group id
_GroupKey g_id{};
{ // TODO: error
@@ -379,7 +379,7 @@ void _handle_HS1_ft_recv_request(
uint8_t* tmp_ptr = reinterpret_cast<uint8_t*>(&msg_id);
std::copy(file_id+TOX_GROUP_PEER_PUBLIC_KEY_SIZE, file_id+TOX_GROUP_PEER_PUBLIC_KEY_SIZE+sizeof(uint32_t), tmp_ptr);
fprintf(stderr, "got a ft request for xxx msg_id %08X\n", msg_id);
fprintf(stderr, "HS: got a ft request for xxx msg_id %08X\n", msg_id);
// get group id
_GroupKey group_id{};
@@ -392,13 +392,13 @@ void _handle_HS1_ft_recv_request(
// do we have that message
if (!peers.count(peer_key)) {
fprintf(stderr, "got ft request for unknown peer\n");
fprintf(stderr, "HS: got ft request for unknown peer\n");
return;
}
const auto& peer = peers.at(peer_key);
if (!peer.dict.count(msg_id)) {
fprintf(stderr, "got ft request for unknown message_id %08X\n", msg_id);
fprintf(stderr, "HS: got ft request for unknown message_id %08X\n", msg_id);
return;
}
@@ -430,7 +430,7 @@ bool _handle_HS1_ft_recv_init(
const uint8_t transfer_id,
const size_t file_size
) {
fprintf(stderr, "-------hs handle ft init\n");
fprintf(stderr, "HS: -------hs handle ft init\n");
// peer id and msg id from file id
// TODO: replace, remote crash
@@ -461,13 +461,13 @@ bool _handle_HS1_ft_recv_init(
if (!pending.count(msg_id)) {
// we did not ask for this
// TODO: accept?
fprintf(stderr, "ft init from peer we did not ask\n");
fprintf(stderr, "HS: ft init from peer we did not ask\n");
return false; // deny
}
if (pending.at(msg_id).peer_number != peer_number) {
// wrong peer ?
fprintf(stderr, "ft init from peer we did not ask while asking someone else\n");
fprintf(stderr, "HS: ft init from peer we did not ask while asking someone else\n");
return false; // deny
}
@@ -501,12 +501,12 @@ void _handle_HS1_ft_recv_data(
// get based on transfer_id
if (!group.transfers.count(std::make_pair(peer_number, transfer_id))) {
if (data_offset != 0) {
fprintf(stderr, "!! got stray tf data from %d tid:%d\n", peer_number, transfer_id);
fprintf(stderr, "HS: !! got stray tf data from %d tid:%d\n", peer_number, transfer_id);
return;
}
// new transfer?
fprintf(stderr, "!! got transfer from %d tid:%d\n", peer_number, transfer_id);
fprintf(stderr, "HS: !! got transfer from %d tid:%d\n", peer_number, transfer_id);
}
// add data to tmp buffer
@@ -529,15 +529,15 @@ void _handle_HS1_REQUEST_LAST_IDS(
size_t curser = 0;
_PeerKey p_key;
_HS1_HAVE(p_key.data.size(), fprintf(stderr, "packet too small, missing pkey\n"); return)
_HS1_HAVE(p_key.data.size(), fprintf(stderr, "HS: packet too small, missing pkey\n"); return)
std::copy(data+curser, data+curser+p_key.data.size(), p_key.data.begin());
curser += p_key.data.size();
_HS1_HAVE(1, fprintf(stderr, "packet too small, missing count\n"); return)
_HS1_HAVE(1, fprintf(stderr, "HS: packet too small, missing count\n"); return)
uint8_t last_msg_id_count = data[curser++];
fprintf(stderr, "got request for last %u ids\n", last_msg_id_count);
fprintf(stderr, "HS: got request for last %u ids\n", last_msg_id_count);
// get group id
_GroupKey g_id{};
@@ -602,17 +602,17 @@ void _handle_HS1_RESPONSE_LAST_IDS(
size_t curser = 0;
_PeerKey p_key;
_HS1_HAVE(p_key.data.size(), fprintf(stderr, "packet too small, missing pkey\n"); return)
_HS1_HAVE(p_key.data.size(), fprintf(stderr, "HS: packet too small, missing pkey\n"); return)
std::copy(data+curser, data+curser+p_key.data.size(), p_key.data.begin());
curser += p_key.data.size();
// TODO: did we ask?
_HS1_HAVE(1, fprintf(stderr, "packet too small, missing count\n"); return)
_HS1_HAVE(1, fprintf(stderr, "HS: packet too small, missing count\n"); return)
uint8_t last_msg_id_count = data[curser++];
fprintf(stderr, "got response with last %u ids:\n", last_msg_id_count);
fprintf(stderr, "HS: got response with last %u ids:\n", last_msg_id_count);
if (last_msg_id_count == 0) {
return;