From b5da6fc4effb80411e65ae91fbfe4a1332679da4 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:08:12 +0200 Subject: [PATCH] dbg: remove support for logfile (#1111) --- include/re_dbg.h | 1 - src/dbg/dbg.c | 44 ++------------------------------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/include/re_dbg.h b/include/re_dbg.h index 8ab1e9370..4db88698e 100644 --- a/include/re_dbg.h +++ b/include/re_dbg.h @@ -114,7 +114,6 @@ typedef void (dbg_print_h)(int level, const char *p, size_t len, void *arg); void dbg_init(int level, enum dbg_flags flags); void dbg_close(void); -int dbg_logfile_set(const char *name); void dbg_handler_set(dbg_print_h *ph, void *arg); void dbg_printf(int level, const char *fmt, ...); const char *dbg_level_str(int level); diff --git a/src/dbg/dbg.c b/src/dbg/dbg.c index e7a19ea84..df3e74847 100644 --- a/src/dbg/dbg.c +++ b/src/dbg/dbg.c @@ -28,14 +28,12 @@ static struct { enum dbg_flags flags; /**< Debug flags */ dbg_print_h *ph; /**< Optional print handler */ void *arg; /**< Handler argument */ - FILE *f; /**< Logfile */ } dbg = { 0, DBG_INFO, DBG_ANSI, NULL, NULL, - NULL, }; static once_flag flag = ONCE_FLAG_INIT; @@ -82,37 +80,6 @@ void dbg_init(int level, enum dbg_flags flags) */ void dbg_close(void) { - if (dbg.f) { - (void)fclose(dbg.f); - dbg.f = NULL; - } -} - - -/** - * Set debug logfile - * - * @param name Name of the logfile, NULL to close - * - * @return 0 if success, otherwise errorcode - */ -int dbg_logfile_set(const char *name) -{ - int err; - - dbg_close(); - - if (!name) - return 0; - - err = fs_fopen(&dbg.f, name, "a+"); - if (err) - return err; - - (void)re_fprintf(dbg.f, "\n===== Log Started: %H", fmt_gmtime, NULL); - (void)fflush(dbg.f); - - return 0; } @@ -180,7 +147,7 @@ static void dbg_vprintf(int level, const char *fmt, va_list ap) } -/* Formatted output to print handler and/or logfile */ +/* Formatted output to print handler */ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) { char buf[256]; @@ -191,10 +158,9 @@ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) if (level > dbg.level) goto out; - if (!dbg.ph && !dbg.f) + if (!dbg.ph) goto out; - len = re_vsnprintf(buf, sizeof(buf), fmt, ap); if (len <= 0) goto out; @@ -204,12 +170,6 @@ static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap) dbg.ph(level, buf, len, dbg.arg); } - /* Output to file */ - if (dbg.f) { - if (fwrite(buf, 1, len, dbg.f) > 0) - (void)fflush(dbg.f); - } - out: dbg_unlock(); }