VirtualBox

Ignore:
Timestamp:
Aug 5, 2024 1:40:30 PM (6 months ago)
Author:
vboxsync
Message:

Additions/VBoxTray: Logger adjustments for debug / release builds. This basically reverts to the behavior before r152549 so that we have different environment variable prefixes (VBOXTRAY_LOG and VBOXTRAY_RELEASE_LOG). Increasing the verbosity via the command line switch (--verbose) will only increase the verbosity for functionality we offer within VBoxTray. Untested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r100204 r105581  
    509509 *
    510510 * @return  IPRT status code.
    511  * @param   pszLogFile          Path to log file to use.
     511 * @param   pszLogFile          Path to log file to use. Can be NULL if not needed.
    512512 */
    513513static int vboxTrayLogCreate(const char *pszLogFile)
     
    515515    /* Create release (or debug) logger (stdout + file). */
    516516    static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
     517#ifdef DEBUG
     518    static const char s_szEnvVarPfx[] = "VBOXTRAY_LOG";
     519    static const char s_szGroupSettings[] = "all.e.l.f";
     520#else
    517521    static const char s_szEnvVarPfx[] = "VBOXTRAY_RELEASE_LOG";
    518 
     522    static const char s_szGroupSettings[] = "all";
     523#endif
    519524    RTERRINFOSTATIC ErrInfo;
    520525    int rc = RTLogCreateEx(&g_pLoggerRelease, s_szEnvVarPfx,
    521526                           RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_USECRLF,
    522                            "all.e", RT_ELEMENTS(s_apszGroups), s_apszGroups, UINT32_MAX,
     527                           s_szGroupSettings, RT_ELEMENTS(s_apszGroups), s_apszGroups, UINT32_MAX,
    523528                           0 /*cBufDescs*/, NULL /*paBufDescs*/, RTLOGDEST_STDOUT,
    524529                           vboxTrayLogHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime,
     
    527532    if (RT_SUCCESS(rc))
    528533    {
     534#ifdef DEBUG
     535        /* Register this logger as the _debug_ logger. */
     536        RTLogSetDefaultInstance(g_pLoggerRelease);
     537#else
    529538        /* Register this logger as the release logger. */
    530539        RTLogRelSetDefaultInstance(g_pLoggerRelease);
    531 
    532         /* Register this logger as the _debug_ logger. */
    533         RTLogSetDefaultInstance(g_pLoggerRelease);
    534 
    535         /* All groups we want to enable logging for VBoxTray. */
    536         const char *apszGroups[] = { "guest_dnd", "shared_clipboard" };
    537         char        szGroupSettings[_1K];
    538 
    539         szGroupSettings[0] = '\0';
    540 
    541         for (size_t i = 0; i < RT_ELEMENTS(apszGroups); i++)
    542         {
    543             if (i > 0)
    544                 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), "+");
     540#endif
     541        /* If verbosity is explicitly set, make sure to increase the logging levels for
     542         * the logging groups we offer functionality for in VBoxTray. */
     543        if (g_cVerbosity)
     544        {
     545            /* All groups we want to enable logging for VBoxTray. */
     546            const char *apszGroups[] = { "guest_dnd", "shared_clipboard" };
     547            char        szGroupSettings[_1K];
     548
     549            szGroupSettings[0] = '\0';
     550
     551            for (size_t i = 0; i < RT_ELEMENTS(apszGroups); i++)
     552            {
     553                if (i > 0)
     554                    rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), "+");
     555                if (RT_SUCCESS(rc))
     556                    rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), apszGroups[i]);
     557                if (RT_FAILURE(rc))
     558                    break;
     559
     560                switch (g_cVerbosity)
     561                {
     562                    case 1:
     563                        rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l");
     564                        break;
     565
     566                    case 2:
     567                        rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2");
     568                        break;
     569
     570                    case 3:
     571                        rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3");
     572                        break;
     573
     574                    case 4:
     575                        RT_FALL_THROUGH();
     576                    default:
     577                        rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3.f");
     578                        break;
     579                }
     580
     581                if (RT_FAILURE(rc))
     582                    break;
     583            }
     584
     585            LogRel(("Verbose log settings are: %s\n", szGroupSettings));
     586
    545587            if (RT_SUCCESS(rc))
    546                 rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), apszGroups[i]);
     588                rc = RTLogGroupSettings(g_pLoggerRelease, szGroupSettings);
    547589            if (RT_FAILURE(rc))
    548                 break;
    549 
    550             switch (g_cVerbosity)
    551             {
    552                 case 1:
    553                     rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l");
    554                     break;
    555 
    556                 case 2:
    557                     rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2");
    558                     break;
    559 
    560                 case 3:
    561                     rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3");
    562                     break;
    563 
    564                 case 4:
    565                     RT_FALL_THROUGH();
    566                 default:
    567                     rc = RTStrCat(szGroupSettings, sizeof(szGroupSettings), ".e.l.l2.l3.f");
    568                     break;
    569             }
    570 
    571             if (RT_FAILURE(rc))
    572                 break;
    573         }
    574 
    575         LogRel(("Verbose log settings are: %s\n", szGroupSettings));
    576 
    577         if (RT_SUCCESS(rc))
    578             rc = RTLogGroupSettings(g_pLoggerRelease, szGroupSettings);
    579         if (RT_FAILURE(rc))
    580             RTMsgError("Setting log group settings failed, rc=%Rrc\n", rc);
     590                RTMsgError("Setting log group settings failed, rc=%Rrc\n", rc);
     591        }
    581592
    582593        /* Explicitly flush the log in case of VBOXTRAY_RELEASE_LOG=buffered. */
Note: See TracChangeset for help on using the changeset viewer.

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