From 48fb8abd6edf8d250cf28cceb3b9ad191c68eff5 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sun, 5 Mar 2023 12:30:08 +0800 Subject: [PATCH] Update logging Use our log function instead of bare printf calls. --- src/packages/game/IZ_app_net.c | 15 ++++++++++----- src/packages/game/data/IZ_list.c | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/packages/game/IZ_app_net.c b/src/packages/game/IZ_app_net.c index 780afbd..ad1367d 100644 --- a/src/packages/game/IZ_app_net.c +++ b/src/packages/game/IZ_app_net.c @@ -1,17 +1,22 @@ #include "IZ_app_net.h" void IZ_AppHandleNetworkingInboundBinaryEvents(struct IZ_App* app, void* binary_raw, size_t len) { + if (len < 1) { + return; + } u8* binary = binary_raw; size_t i; - printf("%lu: Binary", IZ_AppGetTicks(app)); - for (i = 0; i < len; i += 1) { - printf("%c%02x", i == 0 ? '(' : ' ', binary[i]); + char binary_string[len * 3 + 1]; + IZ_memset(binary_string, 0, len * 3 + 1); + sprintf(binary_string, "%02x", binary[0]); + for (i = 1; i < len; i += 1) { + sprintf(binary_string, "%s %02x", binary_string, binary[i]); } - printf(")\n"); + IZ_LogInfo(IZ_LOG_CATEGORY_INPUT, "net/ws", "Received binary(length: %d): %s", len, binary_string); } void IZ_AppHandleNetworkingInboundTextEvents(struct IZ_App* app, const char* text, size_t len) { - printf("%lu: String(%s)\n", IZ_AppGetTicks(app), text); + IZ_LogInfo(IZ_LOG_CATEGORY_INPUT, "net/ws", "Received string(length: %d): %s", len, text); } void IZ_AppHandleOutboundNetworking(struct IZ_App* app) { diff --git a/src/packages/game/data/IZ_list.c b/src/packages/game/data/IZ_list.c index 1dd2538..e8eb82e 100644 --- a/src/packages/game/data/IZ_list.c +++ b/src/packages/game/data/IZ_list.c @@ -57,7 +57,7 @@ void IZ_ListPrintNodeValues(IZ_List* list) { u64 index = 0; printf("\nlist@%p\n", list); do { - printf(" %lu@%p:%u\n", index, *list->iterator, *((unsigned int*)(*list->iterator)->value)); + printf(" %llu@%p:%u\n", index, *list->iterator, *((unsigned int*)(*list->iterator)->value)); index += 1; list->iterator = &(*list->iterator)->next; } while (*list->iterator);