From 8e5ca41879c62a4a9377c9e5b1801bdd3d539cb0 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 26 Jan 2026 18:45:00 +0300 Subject: [PATCH] Replace printf with DEBUG_ macros in debug_performance.c --- tests/debug_performance.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/debug_performance.c b/tests/debug_performance.c index 8c6c7001..0b0e478f 100644 --- a/tests/debug_performance.c +++ b/tests/debug_performance.c @@ -4,44 +4,50 @@ #include #include #include +#include "../lib/u_async.h" +#include "../lib/debug_config.h" static void test_callback(int fd, void* arg) { (void)fd; (void)arg; } int main() { + debug_config_init(); + debug_set_level(DEBUG_LEVEL_TRACE); + debug_set_categories(DEBUG_CATEGORY_ALL); + uasync_t* ua = uasync_create(); if (!ua) return 1; - printf("=== Debug Performance Test ===\n"); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "=== Debug Performance Test ==="); // Test 1: Normal add/remove int sock1 = socket(AF_INET, SOCK_DGRAM, 0); void* id1 = uasync_add_socket(ua, sock1, test_callback, NULL, NULL, NULL); - printf("Added socket %d: id=%p\n", sock1, id1); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Added socket %d: id=%p", sock1, id1); size_t alloc1, free1, alloc2, free2; uasync_get_stats(ua, &alloc1, &free1, &alloc2, &free2); - printf("After add: timers %zu/%zu, sockets %zu/%zu\n", alloc1, free1, alloc2, free2); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "After add: timers %zu/%zu, sockets %zu/%zu", alloc1, free1, alloc2, free2); uasync_remove_socket(ua, id1); - printf("Removed socket %d\n", sock1); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Removed socket %d", sock1); uasync_get_stats(ua, &alloc1, &free1, &alloc2, &free2); - printf("After remove: timers %zu/%zu, sockets %zu/%zu\n", alloc1, free1, alloc2, free2); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "After remove: timers %zu/%zu, sockets %zu/%zu", alloc1, free1, alloc2, free2); close(sock1); // Test 2: Failed add int sock2 = 9999; // Invalid socket void* id2 = uasync_add_socket(ua, sock2, test_callback, NULL, NULL, NULL); - printf("Tried to add invalid socket %d: id=%p\n", sock2, id2); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Tried to add invalid socket %d: id=%p", sock2, id2); uasync_get_stats(ua, &alloc1, &free1, &alloc2, &free2); - printf("After failed add: timers %zu/%zu, sockets %zu/%zu\n", alloc1, free1, alloc2, free2); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "After failed add: timers %zu/%zu, sockets %zu/%zu", alloc1, free1, alloc2, free2); uasync_destroy(ua, 0); - printf("Destroyed uasync\n"); + DEBUG_INFO(DEBUG_CATEGORY_UASYNC, "Destroyed uasync"); return 0; }