VirtualBox

Changeset 99689 in vbox


Ignore:
Timestamp:
May 9, 2023 8:28:38 AM (23 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157237
Message:

Guest Additions/VBoxClient: Dropped the idea of having an own logging facility (VBGHLogXXX) for shared guest/host code again; the (release) logger is flexible enough for this. bugref:10427

Location:
trunk
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk

    r99620 r99689  
    5151# Common Guest / Host sources.
    5252VBOX_GH_SOURCES := \
    53         $(PATH_ROOT)/src/VBox/GuestHost/Log.cpp \
    5453        $(PATH_ROOT)/src/VBox/GuestHost/DisplayServerType.cpp
    5554
  • trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h

    r99658 r99689  
    3737#include <iprt/string.h>
    3838
    39 #include <VBox/GuestHost/Log.h>
    4039#include <VBox/GuestHost/DisplayServerType.h>
    4140
     
    4948int VBClLogCreate(const char *pszLogFile);
    5049int VBClLogCreateEx(const char *pszLogFile, bool fPrintHeader);
     50int VBClLogModify(const char *pszDest, unsigned uVerbosity);
    5151void VBClLogSetLogPrefix(const char *pszPrefix);
    5252void VBClLogDestroy(void);
  • trunk/src/VBox/Additions/x11/VBoxClient/logging.cpp

    r99658 r99689  
    4141#endif
    4242#include <VBox/VBoxGuestLib.h>
    43 
    44 #include <VBox/GuestHost/Log.h>
    4543
    4644#include <package-generated.h>
     
    223221
    224222/**
     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 */
     229static 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/**
    225239 * Logs a fatal error, notifies the desktop environment via a message and
    226240 * exits the application immediately.
     
    233247    va_list va;
    234248    va_start(va, pszFormat);
    235     VBGHLogFatalErrorV(pszFormat, va);
     249    vbclLogV("Fatal Error: ", pszFormat, va);
    236250    va_end(va);
    237251}
     
    246260    va_list va;
    247261    va_start(va, pszFormat);
    248     VBGHLogErrorV(pszFormat, va);
     262    vbclLogV("Error: ", pszFormat, va);
    249263    va_end(va);
    250264}
     
    259273    va_list va;
    260274    va_start(va, pszFormat);
    261     VBGHLogInfoV(pszFormat, va);
     275    vbclLogV("", pszFormat, va);
    262276    va_end(va);
    263277}
     
    275289    va_list va;
    276290    va_start(va, pszFormat);
    277     VBGHLogVerboseV(iLevel, pszFormat, va);
     291    if (iLevel <= g_cVerbosity)
     292        vbclLogV("", pszFormat, va);
    278293    va_end(va);
    279294}
     
    419434
    420435/**
     436 * Destroys the currently active logging instance.
     437 */
     438void 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 */
     452int 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/**
    421481 * Set custom log prefix.
    422482 *
     
    428488}
    429489
    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  
    674674                if (RT_SUCCESS(rc))
    675675                {
    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                    }
    680685                }
    681686
     
    740745        return RTEXITCODE_FAILURE; /* Error message already printed in VBClLogCreateEx(). */
    741746
    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(). */
    753751
    754752    VBClLogInfo("VBoxClient %s r%s started. Verbose level = %d\n",
    755753                RTBldCfgVersion(), RTBldCfgRevisionStr(), g_cVerbosity);
    756 
    757     VBGHLogVerbositySet(g_cVerbosity);
    758754
    759755    /* Try to detect the current session type early on, if needed. */
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r99639 r99689  
    11511151# Common Guest / Host sources.
    11521152VBOX_GH_SOURCES := \
    1153         $(PATH_ROOT)/src/VBox/GuestHost/Log.cpp \
    11541153        $(PATH_ROOT)/src/VBox/GuestHost/DisplayServerType.cpp
    11551154
  • trunk/src/VBox/GuestHost/DisplayServerType.cpp

    r99635 r99689  
    3434#include <iprt/string.h>
    3535#include <iprt/ldr.h>
    36 
    37 #include <VBox/GuestHost/Log.h>
     36#include <iprt/log.h>
     37
    3838#include <VBox/GuestHost/DisplayServerType.h>
    3939
     
    102102VBGHDISPLAYSERVERTYPE VBGHDisplayServerTypeDetect(void)
    103103{
    104     VBGHLogVerbose(1, "Detecting display server ...\n");
     104    LogRel2(("Detecting display server ...\n"));
    105105
    106106    /* Try to connect to the wayland display, assuming it succeeds only when a wayland compositor is active: */
     
    180180        retSessionType = VBGHDISPLAYSERVERTYPE_X11;
    181181
    182     VBGHLogVerbose(1, "Detected via connection: %s\n", VBGHDisplayServerTypeToStr(retSessionType));
     182    LogRel2(("Detected via connection: %s\n", VBGHDisplayServerTypeToStr(retSessionType)));
    183183
    184184    /* If retSessionType is set, we assume we're done here;
     
    197197        waylandDisplayType = VBGHDISPLAYSERVERTYPE_WAYLAND;
    198198
    199     VBGHLogVerbose(1, "Wayland display type is: %s\n", VBGHDisplayServerTypeToStr(waylandDisplayType));
     199    LogRel2(("Wayland display type is: %s\n", VBGHDisplayServerTypeToStr(waylandDisplayType)));
    200200
    201201    VBGHDISPLAYSERVERTYPE xdgSessionType = VBGHDISPLAYSERVERTYPE_NONE;
     
    209209    }
    210210
    211     VBGHLogVerbose(1, "XDG session type is: %s\n", VBGHDisplayServerTypeToStr(xdgSessionType));
     211    LogRel2(("XDG session type is: %s\n", VBGHDisplayServerTypeToStr(xdgSessionType)));
    212212
    213213    VBGHDISPLAYSERVERTYPE xdgCurrentDesktopType = VBGHDISPLAYSERVERTYPE_NONE;
     
    222222    }
    223223
    224     VBGHLogVerbose(1, "XDG current desktop type is: %s\n", VBGHDisplayServerTypeToStr(xdgCurrentDesktopType));
     224    LogRel2(("XDG current desktop type is: %s\n", VBGHDisplayServerTypeToStr(xdgCurrentDesktopType)));
    225225
    226226    /* Set the returning type according to the precedence. */
     
    237237        && (a_Type1 != a_Type2)) \
    238238        { \
    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")); \
    243243            retSessionType = VBGHDISPLAYSERVERTYPE_NONE; \
    244244        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette