From 3640a33077540206ee08cb5ea5f514bfdc1528b7 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 10 Feb 2025 13:30:20 +0100 Subject: [PATCH] os: direct access to logVerbosity No need for complicated 'generic' setter, just make the variable itself available to DDX'es. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/kdrive/ephyr/ephyrinit.c | 7 +++---- hw/xfree86/common/xf86Init.c | 3 ++- hw/xwayland/xwayland.c | 7 +++---- hw/xwin/InitOutput.c | 5 +++-- hw/xwin/glx/indirect.c | 6 ++++-- hw/xwin/winglobals.c | 1 - hw/xwin/winglobals.h | 1 - hw/xwin/winprocarg.c | 5 +++-- os/log.c | 2 +- os/log_priv.h | 8 ++++++++ test/signal-logging.c | 5 +++-- 11 files changed, 30 insertions(+), 20 deletions(-) diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 9306f3367..3e5ce855c 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -28,6 +28,7 @@ #include "dix/dix_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" +#include "os/log_priv.h" #include "os/osdep.h" #include "ephyr.h" @@ -288,10 +289,8 @@ ddxProcessArgument(int argc, char **argv, int i) } else if (!strcmp(argv[i], "-verbosity")) { if (i + 1 < argc && argv[i + 1][0] != '-') { - int verbosity = atoi(argv[i + 1]); - - LogSetParameter(XLOG_VERBOSITY, verbosity); - EPHYR_LOG("set verbosiry to %d\n", verbosity); + logVerbosity = atoi(argv[i + 1]); + EPHYR_LOG("set verbosiry to %d\n", logVerbosity); return 2; } else { diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 2f85c7941..ef62095e5 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -58,6 +58,7 @@ #include "mi/mi_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" +#include "os/log_priv.h" #include "os/osdep.h" #include "servermd.h" @@ -870,7 +871,7 @@ void xf86SetVerbosity(int verb) { xf86Verbose = verb; - LogSetParameter(XLOG_VERBOSITY, verb); + logVerbosity = verb; } void diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index cc85880af..fca1bfdd5 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -41,6 +41,7 @@ #include "os/client_priv.h" #include "os/ddx_priv.h" #include "os/fmt.h" +#include "os/log_priv.h" #include "os/osdep.h" #include "os/xserver_poll.h" @@ -134,7 +135,6 @@ static int init_fd = -1; static int wm_fd = -1; static int listen_fds[5] = { -1, -1, -1, -1, -1 }; static int listen_fd_count = 0; -static int verbosity = 0; static void xwl_show_version(void) @@ -237,12 +237,11 @@ ddxProcessArgument(int argc, char *argv[], int i) val = strtol(argv[i], &end, 0); if (*end == '\0') { - verbosity = val; - LogSetParameter(XLOG_VERBOSITY, verbosity); + logVerbosity = val; return 2; } } - LogSetParameter(XLOG_VERBOSITY, ++verbosity); + logVerbosity++; return 1; } else if (strcmp(argv[i], "-version") == 0) { diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 74775e1e6..16d505e38 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -37,6 +37,7 @@ from The Open Group. #include "dix/dix_priv.h" #include "dix/screenint_priv.h" #include "os/ddx_priv.h" +#include "os/log_priv.h" #include "os/osdep.h" #include "winmsg.h" @@ -643,8 +644,8 @@ OsVendorInit(void) g_pszLogFile = LogInit(g_pszLogFile, ".old"); } - LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose); - LogSetParameter(XLOG_FILE_VERBOSITY, g_iLogVerbose); + logVerbosity = 2; + LogSetParameter(XLOG_FILE_VERBOSITY, logVerbosity); /* Log the version information */ if (serverGeneration == 1) diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c index e34437ace..6dcd27d2a 100644 --- a/hw/xwin/glx/indirect.c +++ b/hw/xwin/glx/indirect.c @@ -78,6 +78,8 @@ #include #endif +#include "os/log_priv.h" + #include "glwindows.h" #include #include @@ -297,7 +299,7 @@ fbConfigsDump(unsigned int n, __GLXconfig * c, PixelFormatRejectStats *rejects) LogMessage(X_INFO, "ignored pixel formats: %d not OpenGL, %d unknown pixel type, %d unaccelerated\n", rejects->notOpenGL, rejects->unknownPixelType, rejects->unaccelerated); - if (g_iLogVerbose < 3) + if (logVerbosity < 3) return; ErrorF @@ -572,7 +574,7 @@ glxWinScreenProbe(ScreenPtr pScreen) if (!wgl_extensions) wgl_extensions = ""; - if (g_iLogVerbose >= 3) { + if (logVerbosity >= 3) { glxLogExtensions("GL_EXTENSIONS: ", gl_extensions); glxLogExtensions("WGL_EXTENSIONS: ", wgl_extensions); } diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index 29abe1970..8f280d9f5 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -69,7 +69,6 @@ const char *g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log"; const char *g_pszLogFile = "XWin.log"; Bool g_fLogFileChanged = FALSE; #endif -int g_iLogVerbose = 2; Bool g_fLogInited = FALSE; char *g_pszCommandLine = NULL; Bool g_fSilentFatalError = FALSE; diff --git a/hw/xwin/winglobals.h b/hw/xwin/winglobals.h index 29535f05a..b4512d5e1 100644 --- a/hw/xwin/winglobals.h +++ b/hw/xwin/winglobals.h @@ -45,7 +45,6 @@ extern const char *g_pszLogFile; #ifdef RELOCATE_PROJECTROOT extern Bool g_fLogFileChanged; #endif -extern int g_iLogVerbose; extern Bool g_fLogInited; extern Bool g_fAuthEnabled; diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index d87c40936..a44639c5b 100644 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -36,8 +36,9 @@ from The Open Group. #endif #include "os/cmdline.h" -#include "os/osdep.h" #include "os/ddx_priv.h" +#include "os/log_priv.h" +#include "os/osdep.h" #include <../xfree86/common/xorgVersion.h> #include "win.h" @@ -996,7 +997,7 @@ ddxProcessArgument(int argc, char *argv[], int i) */ if (IS_OPTION("-logverbose")) { CHECK_ARGS(1); - g_iLogVerbose = atoi(argv[++i]); + logVerbosity = atoi(argv[++i]); return 2; } diff --git a/os/log.c b/os/log.c index d9c23b684..0d417dbe1 100644 --- a/os/log.c +++ b/os/log.c @@ -111,9 +111,9 @@ OR PERFORMANCE OF THIS SOFTWARE. #define DEFAULT_LOG_FILE_VERBOSITY 3 Bool logSync = FALSE; +int logVerbosity = DEFAULT_LOG_VERBOSITY; static int logFileFd = -1; -static int logVerbosity = DEFAULT_LOG_VERBOSITY; static int logFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY; /* Buffer to information logged before the log file is opened. */ diff --git a/os/log_priv.h b/os/log_priv.h index 6d35dfec9..3d5667f61 100644 --- a/os/log_priv.h +++ b/os/log_priv.h @@ -15,4 +15,12 @@ */ extern Bool logSync; +/** + * @brief console log verbosity (stderr) + * + * The verbosity level of logging to console. All messages with verbosity + * level below this one will be written to stderr + */ +extern int logVerbosity; + #endif /* _XSERVER_LOG_PRIV_H */ diff --git a/test/signal-logging.c b/test/signal-logging.c index 22a01631c..f66dfe069 100644 --- a/test/signal-logging.c +++ b/test/signal-logging.c @@ -30,6 +30,7 @@ #include #include "os/fmt.h" +#include "os/log_priv.h" #include "assert.h" #include "misc.h" @@ -149,7 +150,7 @@ number_formatting(void) -0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */ } ; - LogSetParameter(XLOG_VERBOSITY, -1); + logVerbosity = -1; for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++) assert(check_number_format_test(unsigned_tests[i])); @@ -181,7 +182,7 @@ static void logging_format(void) uintptr_t ptr; char *fname = NULL; - LogSetParameter(XLOG_VERBOSITY, -1); + logVerbosity = -1; /* set up buf to contain ".....end" */ memset(buf, '.', sizeof(buf));