Changeset 99658 in vbox for trunk/src/VBox/Additions/x11/VBoxClient
- Timestamp:
- May 8, 2023 9:35:54 AM (23 months ago)
- svn:sync-xref-src-repo-rev:
- 157187
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r99620 r99658 48 48 49 49 int VBClLogCreate(const char *pszLogFile); 50 int VBClLogCreateEx(const char *pszLogFile, bool fPrintHeader); 50 51 void VBClLogSetLogPrefix(const char *pszPrefix); 51 52 void VBClLogDestroy(void); -
trunk/src/VBox/Additions/x11/VBoxClient/logging.cpp
r99585 r99658 32 32 #include <iprt/buildconfig.h> 33 33 #include <iprt/file.h> 34 #include <iprt/message.h> 34 35 #include <iprt/process.h> 35 36 #include <iprt/stream.h> … … 365 366 366 367 /** 367 * Creates the default release logger outputting to the specified file. 368 * 369 * Pass NULL to disabled logging. 368 * Creates the default release logger outputting to the specified file, extended version. 370 369 * 371 370 * @return IPRT status code. 372 * @param pszLogFile Filename for log output. NULL disables custom handling. 373 */ 374 int VBClLogCreate(const char *pszLogFile) 371 * @param pszLogFile Filename for log output. Empty filename allowed. 372 * @param fPrintHeader Whether to print the VBoxClient logging header or not. 373 */ 374 int VBClLogCreateEx(const char *pszLogFile, bool fPrintHeader) 375 375 { 376 376 if (!pszLogFile) … … 386 386 RT_ELEMENTS(s_apszGroups), s_apszGroups, UINT32_MAX /*cMaxEntriesPerGroup*/, 387 387 0 /*cBufDescs*/, NULL /*paBufDescs*/, RTLOGDEST_STDOUT | RTLOGDEST_USER, 388 vbClLogHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime,388 fPrintHeader ? vbClLogHeaderFooter : NULL, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime, 389 389 NULL /*pOutputIf*/, NULL /*pvOutputIfUser*/, 390 390 NULL /*pErrInfo*/, "%s", pszLogFile ? pszLogFile : ""); … … 396 396 rc = RTLogSetCustomPrefixCallback(g_pLoggerRelease, vbClLogPrefixCb, NULL); 397 397 if (RT_FAILURE(rc)) 398 VBClLogError("unable to register custom log prefix callback\n");398 RTMsgError("unable to register custom log prefix callback\n"); 399 399 400 400 /* Explicitly flush the log in case of VBOXSERVICE_RELEASE_LOG=buffered. */ 401 401 RTLogFlush(g_pLoggerRelease); 402 402 } 403 else 404 RTMsgError("Failed to create release log '%s', rc=%Rrc\n", pszLogFile, rc); 403 405 404 406 return rc; … … 406 408 407 409 /** 410 * Creates the default release logger outputting to the specified file. 411 * 412 * @return IPRT status code. 413 * @param pszLogFile Filename for log output. Empty filename allowed. 414 */ 415 int VBClLogCreate(const char *pszLogFile) 416 { 417 return VBClLogCreateEx(pszLogFile, true /* fPrintHeader */); 418 } 419 420 /** 408 421 * Set custom log prefix. 409 422 * -
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r99620 r99658 64 64 #define VBOXCLIENT_OPT_VMSVGA_SESSION VBOXCLIENT_OPT_SERVICES + 5 65 65 #define VBOXCLIENT_OPT_DISPLAY VBOXCLIENT_OPT_SERVICES + 6 66 #define VBOXCLIENT_OPT_SESSION_TYPE VBOXCLIENT_OPT_SERVICES + 7 66 #define VBOXCLIENT_OPT_SESSION_DETECT VBOXCLIENT_OPT_SERVICES + 7 67 #define VBOXCLIENT_OPT_SESSION_TYPE VBOXCLIENT_OPT_SERVICES + 8 67 68 68 69 … … 327 328 #endif 328 329 RTPrintf(" --session-type specifies the session type to use (auto, x11, wayland)\n"); 330 RTPrintf(" --session-detect detects and prints the current session type\n" 331 " (exit code 0 if detection succeeded)\n"); 329 332 RTPrintf(" -f, --foreground run in the foreground (no daemonizing)\n"); 330 333 RTPrintf(" -d, --nodaemon continues running as a system service\n"); … … 534 537 { "--display", VBOXCLIENT_OPT_DISPLAY, RTGETOPT_REQ_NOTHING }, 535 538 #endif 539 { "--session-detect", VBOXCLIENT_OPT_SESSION_DETECT, RTGETOPT_REQ_NOTHING }, 536 540 { "--session-type", VBOXCLIENT_OPT_SESSION_TYPE, RTGETOPT_REQ_STRING } 537 541 }; … … 665 669 } 666 670 #endif 671 case VBOXCLIENT_OPT_SESSION_DETECT: 672 { 673 rc = VBClLogCreateEx("" /* No file logging */, false /* No header */); 674 if (RT_SUCCESS(rc)) 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; 680 } 681 682 return RTEXITCODE_FAILURE; 683 } 684 667 685 case VBOXCLIENT_OPT_SESSION_TYPE: 668 686 { … … 720 738 rc = VBClLogCreate(g_szLogFile[0] ? g_szLogFile : ""); 721 739 if (RT_FAILURE(rc)) 722 return RTMsgErrorExitFailure("Failed to create release log '%s', rc=%Rrc\n", 723 g_szLogFile[0] ? g_szLogFile : "<None>", rc); 740 return RTEXITCODE_FAILURE; /* Error message already printed in VBClLogCreateEx(). */ 724 741 725 742 if (!fDaemonise)
Note:
See TracChangeset
for help on using the changeset viewer.