VirtualBox

Ignore:
Timestamp:
Jun 28, 2011 12:33:34 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72522
Message:

Main/VBoxSVC: add release logging, with conservative log rotation settings enabled by default

Location:
trunk/src/VBox/Main/src-server/xpcom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/xpcom/server.cpp

    r37356 r37666  
    4343#include <iprt/getopt.h>
    4444#include <iprt/message.h>
     45#include <iprt/string.h>
    4546#include <iprt/stream.h>
    4647#include <iprt/path.h>
     
    792793    static const RTGETOPTDEF s_aOptions[] =
    793794    {
    794         { "--automate",       'a', RTGETOPT_REQ_NOTHING },
    795         { "--auto-shutdown",  'A', RTGETOPT_REQ_NOTHING },
    796         { "--daemonize",      'd', RTGETOPT_REQ_NOTHING },
    797         { "--pidfile",        'p', RTGETOPT_REQ_STRING  },
     795        { "--automate",         'a', RTGETOPT_REQ_NOTHING },
     796        { "--auto-shutdown",    'A', RTGETOPT_REQ_NOTHING },
     797        { "--daemonize",        'd', RTGETOPT_REQ_NOTHING },
     798        { "--pidfile",          'p', RTGETOPT_REQ_STRING  },
     799        { "--logfile",          'F', RTGETOPT_REQ_STRING },
     800        { "--logrotate",        'R', RTGETOPT_REQ_UINT32 },
     801        { "--logsize",          'S', RTGETOPT_REQ_UINT64 },
     802        { "--loginterval",      'I', RTGETOPT_REQ_UINT32 }
    798803    };
    799804
     805    const char      *pszLogFile = NULL;
     806    uint32_t        cHistory = 10;                  // enable log rotation, 10 files
     807    uint32_t        uHistoryFileTime = RT_SEC_1DAY; // max 1 day per file
     808    uint64_t        uHistoryFileSize = 100 * _1M;   // max 100MB per file
    800809    bool            fDaemonize = false;
    801810    PRFileDesc      *daemon_pipe_wr = nsnull;
     
    839848            }
    840849
     850            case 'F':
     851                pszLogFile = ValueUnion.psz;
     852                break;
     853
     854            case 'R':
     855                cHistory = ValueUnion.u32;
     856                break;
     857
     858            case 'S':
     859                uHistoryFileSize = ValueUnion.u64;
     860                break;
     861
     862            case 'I':
     863                uHistoryFileTime = ValueUnion.u32;
     864                break;
     865
    841866            case 'h':
    842867            {
     
    862887    }
    863888
    864     nsresult    rc;
     889    nsresult rc;
     890
     891    if (!pszLogFile)
     892    {
     893        char szLogFile[RTPATH_MAX];
     894        vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
     895        if (RT_SUCCESS(vrc))
     896            vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log");
     897        if (RT_SUCCESS(vrc))
     898            pszLogFile = RTStrDup(szLogFile);
     899    }
     900    VBoxSVCLogRelCreate(pszLogFile, cHistory, uHistoryFileTime, uHistoryFileSize);
    865901
    866902    daemon_pipe_wr = PR_GetInheritedFD(VBOXSVC_STARTUP_PIPE_NAME);
  • trunk/src/VBox/Main/src-server/xpcom/server_module.cpp

    r37010 r37666  
    4949#include <VBox/err.h>
    5050
     51#include <iprt/assert.h>
    5152#include <iprt/param.h>
    5253#include <iprt/path.h>
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