VirtualBox

Changeset 83612 in vbox


Ignore:
Timestamp:
Apr 7, 2020 5:17:25 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137025
Message:

Guest Control/VBoxSerivce: Include a timestamp in the logfile format to make logs more unique across multiple runs. bugref:9320

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r83595 r83612  
    22662266            pszSuffix = strchr(g_szLogFile, '\0');
    22672267        size_t cchBase = pszSuffix - g_szLogFile;
     2268
     2269        RTTIMESPEC Now;
     2270        RTTimeNow(&Now);
     2271        char szTime[64];
     2272        RTTimeSpecToString(&Now, szTime, sizeof(szTime));
     2273
     2274        /* Replace out characters not allowed on Windows platforms, put in by RTTimeSpecToString(). */
     2275        static const RTUNICP s_uszValidRangePairs[] =
     2276        {
     2277            ' ', ' ',
     2278            '(', ')',
     2279            '-', '.',
     2280            '0', '9',
     2281            'A', 'Z',
     2282            'a', 'z',
     2283            '_', '_',
     2284            0xa0, 0xd7af,
     2285            '\0'
     2286        };
     2287        ssize_t cReplaced = RTStrPurgeComplementSet(szTime, s_uszValidRangePairs, '_' /* chReplacement */);
     2288        AssertReturn(cReplaced, VERR_INVALID_UTF8_ENCODING);
     2289
    22682290#ifndef DEBUG
    2269         RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%s%s",
    2270                     cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, pSessionStartupInfo->szUser, pszSuffix);
     2291        RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%s-%s%s",
     2292                    cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, pSessionStartupInfo->szUser, szTime, pszSuffix);
    22712293#else
    2272         RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%RU32-%s%s",
     2294        RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%RU32-%s-%s%s",
    22732295                    cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, uCtrlSessionThread,
    2274                     pSessionStartupInfo->szUser, pszSuffix);
     2296                    pSessionStartupInfo->szUser, szTime, pszSuffix);
    22752297#endif
    22762298        apszArgs[idxArg++] = "--logfile";
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