Changeset 99689 in vbox
- Timestamp:
- May 9, 2023 8:28:38 AM (23 months ago)
- svn:sync-xref-src-repo-rev:
- 157237
- Location:
- trunk
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
r99620 r99689 51 51 # Common Guest / Host sources. 52 52 VBOX_GH_SOURCES := \ 53 $(PATH_ROOT)/src/VBox/GuestHost/Log.cpp \54 53 $(PATH_ROOT)/src/VBox/GuestHost/DisplayServerType.cpp 55 54 -
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r99658 r99689 37 37 #include <iprt/string.h> 38 38 39 #include <VBox/GuestHost/Log.h>40 39 #include <VBox/GuestHost/DisplayServerType.h> 41 40 … … 49 48 int VBClLogCreate(const char *pszLogFile); 50 49 int VBClLogCreateEx(const char *pszLogFile, bool fPrintHeader); 50 int VBClLogModify(const char *pszDest, unsigned uVerbosity); 51 51 void VBClLogSetLogPrefix(const char *pszPrefix); 52 52 void VBClLogDestroy(void); -
trunk/src/VBox/Additions/x11/VBoxClient/logging.cpp
r99658 r99689 41 41 #endif 42 42 #include <VBox/VBoxGuestLib.h> 43 44 #include <VBox/GuestHost/Log.h>45 43 46 44 #include <package-generated.h> … … 223 221 224 222 /** 223 * Logs a message with a given prefix, format string and a va_list. 224 * 225 * @param pszPrefix Log prefix to use. 226 * @param pszFormat Format string to use. 227 * @param va va_list to use. 228 */ 229 static void vbclLogV(const char *pszPrefix, const char *pszFormat, va_list va) 230 { 231 char *psz = NULL; 232 RTStrAPrintfV(&psz, pszFormat, va); 233 AssertPtrReturnVoid(psz); 234 LogRel(("%s%s", pszPrefix ? pszPrefix : "", psz)); 235 RTStrFree(psz); 236 } 237 238 /** 225 239 * Logs a fatal error, notifies the desktop environment via a message and 226 240 * exits the application immediately. … … 233 247 va_list va; 234 248 va_start(va, pszFormat); 235 VBGHLogFatalErrorV(pszFormat, va);249 vbclLogV("Fatal Error: ", pszFormat, va); 236 250 va_end(va); 237 251 } … … 246 260 va_list va; 247 261 va_start(va, pszFormat); 248 VBGHLogErrorV(pszFormat, va);262 vbclLogV("Error: ", pszFormat, va); 249 263 va_end(va); 250 264 } … … 259 273 va_list va; 260 274 va_start(va, pszFormat); 261 VBGHLogInfoV(pszFormat, va);275 vbclLogV("", pszFormat, va); 262 276 va_end(va); 263 277 } … … 275 289 va_list va; 276 290 va_start(va, pszFormat); 277 VBGHLogVerboseV(iLevel, pszFormat, va); 291 if (iLevel <= g_cVerbosity) 292 vbclLogV("", pszFormat, va); 278 293 va_end(va); 279 294 } … … 419 434 420 435 /** 436 * Destroys the currently active logging instance. 437 */ 438 void VBClLogDestroy(void) 439 { 440 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); 441 } 442 443 /** 444 * Modifies the (release) log settings. 445 * 446 * @returns VBox status code. 447 * @param pszDest Log destination string to set. 448 * @param uVerbosity Verbosity level to set. 449 * 450 * @note Errors will be logged to stderr. 451 */ 452 int VBClLogModify(const char *pszDest, unsigned uVerbosity) 453 { 454 AssertPtrReturn(pszDest, VERR_INVALID_POINTER); 455 AssertPtrReturn(g_pLoggerRelease, VERR_INVALID_POINTER); 456 457 int rc = RTLogDestinations(g_pLoggerRelease, pszDest); 458 if (RT_SUCCESS(rc)) 459 { 460 #define LOG_GROUP_SET_BREAK(a_Val) \ 461 rc = RTLogGroupSettings(g_pLoggerRelease, "all.e" a_Val); break; 462 463 switch (uVerbosity) 464 { 465 case 0: LOG_GROUP_SET_BREAK(""); 466 case 1: LOG_GROUP_SET_BREAK(".l"); 467 case 2: LOG_GROUP_SET_BREAK(".l.l2"); 468 case 3: LOG_GROUP_SET_BREAK(".l.l2.l3"); 469 default: LOG_GROUP_SET_BREAK(".l.l2.l3.l4"); 470 } 471 #undef LOG_GROUP_SET_BREAK 472 } 473 474 if (RT_FAILURE(rc)) /* Print to stderr in the hope that anyone can read this. */ 475 RTMsgError("Failed to set/modify log output, rc=%Rrc", rc); 476 477 return rc; 478 } 479 480 /** 421 481 * Set custom log prefix. 422 482 * … … 428 488 } 429 489 430 /**431 * Destroys the currently active logging instance.432 */433 void VBClLogDestroy(void)434 {435 RTLogDestroy(RTLogRelSetDefaultInstance(NULL));436 }437 -
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r99660 r99689 674 674 if (RT_SUCCESS(rc)) 675 675 { 676 VBGHLogVerbositySet(2); 677 VBGHDISPLAYSERVERTYPE const enmType = VBGHDisplayServerTypeDetect(); 678 VBClLogInfo("Detected session: %s\n", VBGHDisplayServerTypeToStr(enmType)); 679 return enmType != VBGHDISPLAYSERVERTYPE_NONE ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 676 /* Make sure that we increase the verbosity (if needed), to gain some more insights 677 * when detecting the display server. */ 678 rc = VBClLogModify("stdout", g_cVerbosity); 679 if (RT_SUCCESS(rc)) 680 { 681 VBGHDISPLAYSERVERTYPE const enmType = VBGHDisplayServerTypeDetect(); 682 VBClLogInfo("Detected session: %s\n", VBGHDisplayServerTypeToStr(enmType)); 683 return enmType != VBGHDISPLAYSERVERTYPE_NONE ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 684 } 680 685 } 681 686 … … 740 745 return RTEXITCODE_FAILURE; /* Error message already printed in VBClLogCreateEx(). */ 741 746 742 if (!fDaemonise) 743 { 744 /* If the user is running in "no daemon" mode, send critical logging to stdout as well. */ 745 PRTLOGGER pReleaseLog = RTLogRelGetDefaultInstance(); 746 if (pReleaseLog) 747 { 748 rc = RTLogDestinations(pReleaseLog, "stdout"); 749 if (RT_FAILURE(rc)) 750 return RTMsgErrorExitFailure("Failed to redivert error output, rc=%Rrc", rc); 751 } 752 } 747 /* If the user is running in "no daemon" mode, send critical logging to stdout as well. */ 748 rc = VBClLogModify(fDaemonise ? "" : "stdout", g_cVerbosity); 749 if (RT_FAILURE(rc)) 750 return RTEXITCODE_FAILURE; /* Error message already printed in VBClLogModify(). */ 753 751 754 752 VBClLogInfo("VBoxClient %s r%s started. Verbose level = %d\n", 755 753 RTBldCfgVersion(), RTBldCfgRevisionStr(), g_cVerbosity); 756 757 VBGHLogVerbositySet(g_cVerbosity);758 754 759 755 /* Try to detect the current session type early on, if needed. */ -
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r99639 r99689 1151 1151 # Common Guest / Host sources. 1152 1152 VBOX_GH_SOURCES := \ 1153 $(PATH_ROOT)/src/VBox/GuestHost/Log.cpp \1154 1153 $(PATH_ROOT)/src/VBox/GuestHost/DisplayServerType.cpp 1155 1154 -
trunk/src/VBox/GuestHost/DisplayServerType.cpp
r99635 r99689 34 34 #include <iprt/string.h> 35 35 #include <iprt/ldr.h> 36 37 #include <VBox/GuestHost/Log.h> 36 #include <iprt/log.h> 37 38 38 #include <VBox/GuestHost/DisplayServerType.h> 39 39 … … 102 102 VBGHDISPLAYSERVERTYPE VBGHDisplayServerTypeDetect(void) 103 103 { 104 VBGHLogVerbose(1, "Detecting display server ...\n");104 LogRel2(("Detecting display server ...\n")); 105 105 106 106 /* Try to connect to the wayland display, assuming it succeeds only when a wayland compositor is active: */ … … 180 180 retSessionType = VBGHDISPLAYSERVERTYPE_X11; 181 181 182 VBGHLogVerbose(1, "Detected via connection: %s\n", VBGHDisplayServerTypeToStr(retSessionType));182 LogRel2(("Detected via connection: %s\n", VBGHDisplayServerTypeToStr(retSessionType))); 183 183 184 184 /* If retSessionType is set, we assume we're done here; … … 197 197 waylandDisplayType = VBGHDISPLAYSERVERTYPE_WAYLAND; 198 198 199 VBGHLogVerbose(1, "Wayland display type is: %s\n", VBGHDisplayServerTypeToStr(waylandDisplayType));199 LogRel2(("Wayland display type is: %s\n", VBGHDisplayServerTypeToStr(waylandDisplayType))); 200 200 201 201 VBGHDISPLAYSERVERTYPE xdgSessionType = VBGHDISPLAYSERVERTYPE_NONE; … … 209 209 } 210 210 211 VBGHLogVerbose(1, "XDG session type is: %s\n", VBGHDisplayServerTypeToStr(xdgSessionType));211 LogRel2(("XDG session type is: %s\n", VBGHDisplayServerTypeToStr(xdgSessionType))); 212 212 213 213 VBGHDISPLAYSERVERTYPE xdgCurrentDesktopType = VBGHDISPLAYSERVERTYPE_NONE; … … 222 222 } 223 223 224 VBGHLogVerbose(1, "XDG current desktop type is: %s\n", VBGHDisplayServerTypeToStr(xdgCurrentDesktopType));224 LogRel2(("XDG current desktop type is: %s\n", VBGHDisplayServerTypeToStr(xdgCurrentDesktopType))); 225 225 226 226 /* Set the returning type according to the precedence. */ … … 237 237 && (a_Type1 != a_Type2)) \ 238 238 { \ 239 VBGHLogError("Unable to reliably detect desktop environment:\n"); \240 VBGHLogError("Mismatch between %s (%s) and %s (%s) detected! This might indicate a misconfigured and/or broken system!\n", \241 #a_Type1, VBGHDisplayServerTypeToStr(a_Type1), #a_Type2, VBGHDisplayServerTypeToStr(a_Type2)); \242 VBGHLogError("Use --session-type to override this detection.\n"); \239 LogRel(("Unable to reliably detect desktop environment:\n")); \ 240 LogRel(("Mismatch between %s (%s) and %s (%s) detected! This might indicate a misconfigured and/or broken system!\n", \ 241 #a_Type1, VBGHDisplayServerTypeToStr(a_Type1), #a_Type2, VBGHDisplayServerTypeToStr(a_Type2))); \ 242 LogRel(("Use --session-type to override this detection.\n")); \ 243 243 retSessionType = VBGHDISPLAYSERVERTYPE_NONE; \ 244 244 }
Note:
See TracChangeset
for help on using the changeset viewer.