diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2023-05-05 08:48:06 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2023-05-05 08:48:06 +0000 |
commit | 6c5addf288148bb0715fb715f91d0173bded045c (patch) | |
tree | ef488eb50023353b144e09abf65dee48f595a5c8 | |
parent | 205289fd25a3353286b08219df14d2dd7c1257ea (diff) | |
download | VirtualBox-svn-6c5addf288148bb0715fb715f91d0173bded045c.tar.gz |
Guest / Host: Added VBGHLogVerbosity[Get|Set](), removed external (global) as a requirement. bugref:10427
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@99616 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r-- | include/VBox/GuestHost/Log.h | 2 | ||||
-rw-r--r-- | src/VBox/Additions/x11/VBoxClient/main.cpp | 2 | ||||
-rw-r--r-- | src/VBox/GuestHost/Log.cpp | 57 |
3 files changed, 44 insertions, 17 deletions
diff --git a/include/VBox/GuestHost/Log.h b/include/VBox/GuestHost/Log.h index 6b4b997b9d8..1332b41b710 100644 --- a/include/VBox/GuestHost/Log.h +++ b/include/VBox/GuestHost/Log.h @@ -52,6 +52,8 @@ void VBGHLogFatalError(const char *pszFormat, ...); void VBGHLogFatalErrorV(const char *pszFormat, va_list va); void VBGHLogVerbose(unsigned iLevel, const char *pszFormat, ...); void VBGHLogVerboseV(unsigned iLevel, const char *pszFormat, va_list va); +void VBGHLogVerbositySet(unsigned iLevel); +unsigned VBGHLogVerbosityGet(void); #endif /* !VBOX_INCLUDED_GuestHost_Log_h */ diff --git a/src/VBox/Additions/x11/VBoxClient/main.cpp b/src/VBox/Additions/x11/VBoxClient/main.cpp index 5b3a8ecd955..7c8b1da3298 100644 --- a/src/VBox/Additions/x11/VBoxClient/main.cpp +++ b/src/VBox/Additions/x11/VBoxClient/main.cpp @@ -737,6 +737,8 @@ int main(int argc, char *argv[]) VBClLogInfo("VBoxClient %s r%s started. Verbose level = %d\n", RTBldCfgVersion(), RTBldCfgRevisionStr(), g_cVerbosity); + VBGHLogVerbositySet(g_cVerbosity); + /* Try to detect the current session type early on, if needed. */ if (g_enmSessionType == VBGHSESSIONTYPE_AUTO) { diff --git a/src/VBox/GuestHost/Log.cpp b/src/VBox/GuestHost/Log.cpp index 7894634c430..7b70b52adf4 100644 --- a/src/VBox/GuestHost/Log.cpp +++ b/src/VBox/GuestHost/Log.cpp @@ -36,9 +36,9 @@ /********************************************************************************************************************************* -* Externals * +* Globals * *********************************************************************************************************************************/ -extern unsigned g_cVerbosity; /* Current verbosity level; must be provided by the implementation using this code. */ +static unsigned g_vbghLogVerbosity = 0; /* Current guest/host log verbosity level. */ /********************************************************************************************************************************* @@ -129,8 +129,8 @@ int VBGHShowNotify(const char *pszHeader, const char *pszFormat, ...) /** * Logs an error message with a va_list. * - * @param pszFormat Format string.. - * @param va Format arguments. + * @param pszFormat Format string.. + * @param va Format arguments. */ void VBGHLogErrorV(const char *pszFormat, va_list va) { @@ -140,7 +140,7 @@ void VBGHLogErrorV(const char *pszFormat, va_list va) /** * Logs an error message to the (release) logging instance. * - * @param pszFormat Format string to log. + * @param pszFormat Format string to log. */ void VBGHLogError(const char *pszFormat, ...) { @@ -150,8 +150,8 @@ void VBGHLogError(const char *pszFormat, ...) /** * Logs a info message with a va_list. * - * @param pszFormat Format string.. - * @param va Format arguments. + * @param pszFormat Format string.. + * @param va Format arguments. */ void VBGHLogInfoV(const char *pszFormat, va_list va) { @@ -171,8 +171,8 @@ void VBGHLogInfo(const char *pszFormat, ...) /** * Logs a fatal error, notifies the desktop environment via a message (if available). * - * @param pszFormat Format string.. - * @param va Format arguments. + * @param pszFormat Format string.. + * @param va Format arguments. */ void VBGHLogFatalErrorV(const char *pszFormat, va_list va) { @@ -196,13 +196,13 @@ void VBGHLogFatalError(const char *pszFormat, ...) * Displays a verbose message based on the currently * set global verbosity level. * - * @param iLevel Minimum log level required to display this message. - * @param pszFormat Format string. - * @param ... Format arguments. + * @param iLevel Minimum log level required to display this message. + * @param pszFormat Format string. + * @param ... Format arguments. */ void VBGHLogVerbose(unsigned iLevel, const char *pszFormat, ...) { - if (iLevel <= g_cVerbosity) + if (iLevel <= g_vbghLogVerbosity) VBGH_LOG_VA("", pszFormat); } @@ -210,13 +210,36 @@ void VBGHLogVerbose(unsigned iLevel, const char *pszFormat, ...) * Displays a verbose message based on the currently * set global verbosity level with a va_list. * - * @param iLevel Minimum log level required to display this message. - * @param pszFormat Format string. - * @param va Format arguments. + * @param iLevel Minimum log level required to display this message. + * @param pszFormat Format string. + * @param va Format arguments. */ void VBGHLogVerboseV(unsigned iLevel, const char *pszFormat, va_list va) { - if (iLevel <= g_cVerbosity) + if (iLevel <= g_vbghLogVerbosity) VBGH_LOG_VALIST("", pszFormat, va); } +/** + * Sets the verbosity level. + * @param iLevel Verbosity level to set. + * + * @note Not thread safe. + */ +void VBGHLogVerbositySet(unsigned iLevel) +{ + g_vbghLogVerbosity = iLevel; +} + +/** + * Gets the current verbosity level. + * + * @returns The current verbosity level. + * + * @note Not thread safe. + */ +unsigned VBGHLogVerbosityGet(void) +{ + return g_vbghLogVerbosity; +} + |