From afd187acc34d223e5a5ecb4ad134c8fd491de4a1 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 26 Mar 2023 10:43:03 +0200 Subject: [PATCH] Allow logging without logfile --- log.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/log.cpp b/log.cpp index f7e65a5..8baa580 100644 --- a/log.cpp +++ b/log.cpp @@ -56,10 +56,7 @@ void closelog() void dolog(const log_level_t ll, const char *fmt, ...) { - if ((ll < log_level_file && ll < log_level_screen) || !logfile) - return; - - if (!lfh) { + if (!lfh && logfile != nullptr) { #if !defined(ESP32) lfh = fopen(logfile, "a+"); if (!lfh) @@ -96,7 +93,7 @@ void dolog(const log_level_t ll, const char *fmt, ...) va_end(ap); #if !defined(ESP32) - if (ll >= log_level_file) + if (ll >= log_level_file && lfh != nullptr) fprintf(lfh, "%s%s\n", ts_str, str); #endif