From 52cd8d749bacde975308dbdccb5f41cef6c22734 Mon Sep 17 00:00:00 2001 From: Matthew Kilgore Date: Fri, 6 Dec 2024 10:31:25 -0500 Subject: [PATCH] Add logging Constants, Adjust _LogMinLevel The new logging constants relate to the return values from _LogMinLevel. Additionally _LogMinLevel now returns 5 when no logging is enabled. --- internal/c/libqb/src/logging/logging.cpp | 5 ++++- internal/support/include/beforefirstline.bi | 6 ++++++ tests/compile_tests/logging/consts.bas | 4 ++++ tests/compile_tests/logging/consts.output | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/compile_tests/logging/consts.bas create mode 100644 tests/compile_tests/logging/consts.output diff --git a/internal/c/libqb/src/logging/logging.cpp b/internal/c/libqb/src/logging/logging.cpp index 4454e71ce..cff8ccbf8 100644 --- a/internal/c/libqb/src/logging/logging.cpp +++ b/internal/c/libqb/src/logging/logging.cpp @@ -36,6 +36,9 @@ static uint8_t enabled_scopes[static_cast(logscope::Count)] = { }; uint32_t func__logminlevel() { + if (!logging_enabled) + return 5; + switch (minimum_level) { case loglevel::Trace: return 1; case loglevel::Information: return 2; @@ -43,7 +46,7 @@ uint32_t func__logminlevel() { case loglevel::Error: return 4; } - return 1; + return 5; } const char *logLevelName(loglevel lvl) { diff --git a/internal/support/include/beforefirstline.bi b/internal/support/include/beforefirstline.bi index 7ca784897..43a4a43e3 100644 --- a/internal/support/include/beforefirstline.bi +++ b/internal/support/include/beforefirstline.bi @@ -261,3 +261,9 @@ CONST _ERR_PATH_FILE_ACCESS_ERROR = 75 CONST _ERR_PATH_NOT_FOUND = 76 CONST _ERR_INVALID_HANDLE = 258 +' Logging constants for _LOGMINLEVEL +CONST _LOG_TRACE = 1 +CONST _LOG_INFO = 2 +CONST _LOG_WARN = 3 +CONST _LOG_ERROR = 4 +CONST _LOG_NONE = 5 diff --git a/tests/compile_tests/logging/consts.bas b/tests/compile_tests/logging/consts.bas new file mode 100644 index 000000000..202512ca2 --- /dev/null +++ b/tests/compile_tests/logging/consts.bas @@ -0,0 +1,4 @@ +$Console:Only + +Print _LOG_TRACE; _LOG_INFO; _LOG_WARN; _LOG_ERROR +System diff --git a/tests/compile_tests/logging/consts.output b/tests/compile_tests/logging/consts.output new file mode 100644 index 000000000..ce24d7e57 --- /dev/null +++ b/tests/compile_tests/logging/consts.output @@ -0,0 +1 @@ + 1 2 3 4