From 0df920a66fc34c2e84134f09d1415066fb4ee712 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Wed, 17 May 2023 17:35:09 +0200 Subject: Replace printf with logs --- src/application.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/application.c b/src/application.c index 24ac7ba..fd99780 100644 --- a/src/application.c +++ b/src/application.c @@ -1,9 +1,11 @@ /* See LICENSE file for copyright and license details. */ +#include #include #include #include #include +#include #include "application.h" #include "event.h" #include "window.h" @@ -82,9 +84,21 @@ cherry_application_main_loop(CherryApplication *app) } } +static void +print_log(Log *log, char *fmt, char *attr) +{ + char *message = calloc(strlen(fmt) + strlen(attr) + 1, sizeof(char)); + sprintf(message, fmt, attr); + log_debug(log, message); + + free(message); +} + int cherry_application_run(CherryApplication *app, int argc, char **argv) { + Log *log = log_create("cherry_application_run"); + if (app == NULL) exit(1); /* setup display/screen */ @@ -104,7 +118,7 @@ cherry_application_run(CherryApplication *app, int argc, char **argv) CherryWindow *w = clist_iterator_next(&it); char *wnd_name = cherry_window_get_title(w); - printf("Destroying window: %s\n", wnd_name); + print_log(log, "Destroying window: %s", wnd_name); XFree(wnd_name); XFreeGC(app->display, w->gc); -- cgit v1.2.3