VirtualBox

vbox的更動 36344 路徑 trunk/include


忽略:
時間撮記:
2011-3-22 下午02:29:37 (14 年 以前)
作者:
vboxsync
訊息:

Runtime/log: implement log rotation, adapt all code creating log files and make use of it in the webservice

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/iprt/log.h

    r33540 r36344  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2011 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    165165
    166166/**
     167 * Logger phase.
     168 *
     169 * Used for signalling the log header/footer callback what to do.
     170 */
     171typedef enum RTLOGPHASE
     172{
     173    /** Begin of the logging. */
     174    RTLOGPHASE_BEGIN = 0,
     175    /** End of the logging. */
     176    RTLOGPHASE_END,
     177    /** Before rotating the log file. */
     178    RTLOGPHASE_PREROTATE,
     179    /** After rotating the log file. */
     180    RTLOGPHASE_POSTROTATE
     181} RTLOGPHASE;
     182
     183
     184/**
    167185 * Logger function.
    168186 *
     
    191209/** Pointer to logger function. */
    192210typedef RCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC;
     211
     212/**
     213 * Header/footer message callback.
     214 *
     215 * @param   pLogger     Pointer to the logger instance.
     216 * @param   pszFormat   Format string.
     217 * @param   ...         Optional arguments specified in the format string.
     218 */
     219typedef DECLCALLBACK(void) FNRTLOGPHASEMSG(PRTLOGGER pLogger, const char *pszFormat, ...);
     220/** Pointer to header/footer message callback function. */
     221typedef FNRTLOGPHASEMSG *PFNRTLOGPHASEMSG;
     222
     223/**
     224 * Log file header/footer callback.
     225 *
     226 * @param   pLogger     Pointer to the logger instance.
     227 * @param   enmLogPhase Indicates at what time the callback is invoked.
     228 */
     229typedef DECLCALLBACK(void) FNRTLOGPHASE(PRTLOGGER pLogger, RTLOGPHASE enmLogPhase, PFNRTLOGPHASEMSG pfnLogPhaseMsg);
     230/** Pointer to log header/footer callback function. */
     231typedef FNRTLOGPHASE *PFNRTLOGPHASE;
    193232
    194233/**
     
    247286
    248287#ifndef IN_RC
     288
     289#ifdef IN_RING3
     290/**
     291 * File logging bits for the logger.
     292 */
     293typedef struct RTLOGGERFILE
     294{
     295    /** Pointer to the function called when starting logging, and when
     296     * ending or starting a new log file as part of history rotation. */
     297    PFNRTLOGPHASE           pfnPhase;
     298    /** Handle to log file (if open). */
     299    RTFILE                  File;
     300    /** Pointer to filename.
     301     * (The memory is allocated in the same block as RTLOGGER.) */
     302    char                   *pszFilename;
     303    /** Log file history settings: number of older files to keep.
     304     * 0 means no history. */
     305    uint32_t                cHistory;
     306    /** Log file history settings: maximum amount of data to put in a file. */
     307    uint64_t                cbHistoryFileMax;
     308    /** Log file history settings: current amount of data in a file. */
     309    uint64_t                cbHistoryFileWritten;
     310    /** Log file history settings: maximum time to use a file. */
     311    uint32_t                uHistoryTimeSlotLength;
     312    /** Log file history settings: in what time slot was the file created. */
     313    uint32_t                uHistoryTimeSlotStart;
     314} RTLOGGERFILE;
     315#else /* !IN_RING3 */
     316typedef void RTLOGGERFILE;
     317#endif /* !IN_RING3 */
     318/** Pointer to file logging bits for the logger. */
     319typedef RTLOGGERFILE *PRTLOGGERFILE;
     320
    249321/**
    250322 * Logger instance structure.
     
    279351    /** Destination flags - RTLOGDEST. */
    280352    uint32_t                fDestFlags;
    281     /** Handle to log file (if open). */
    282     RTFILE                  File;
    283     /** Pointer to filename.
     353    /** currently unused field. */
     354    uint32_t                uUnused;
     355    /** Pointer to the file related logging information.
    284356     * (The memory is allocated in the same block as RTLOGGER.) */
    285     char                   *pszFilename;
     357    PRTLOGGERFILE           pFile;
    286358    /** Pointer to the group name array.
    287359     * (The data is readonly and provided by the user.) */
     
    13851457 *                              logger instance.
    13861458 * @param   fDestFlags          The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
     1459 * @param   pfnPhase            Callback function for starting logging and for ending or starting a new file for log history rotation.
     1460 * @param   cHistory            Number of old log files to keep when performing log history rotation.
     1461 * @param   cbHistoryFileMax    Maximum size of log file when performing history rotation. 0=no size limit.
     1462 * @param   uHistoryTimeSlotLength Maximum time interval per log file when performing history rotation, in seconds. 0=no time limit.
    13871463 * @param   pszFilenameFmt      Log filename format string. Standard RTStrFormat().
    13881464 * @param   ...                 Format arguments.
     
    13901466RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
    13911467                        const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    1392                         uint32_t fDestFlags, const char *pszFilenameFmt, ...);
     1468                        uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
     1469                        uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
     1470                        const char *pszFilenameFmt, ...);
    13931471
    13941472/**
     
    14051483 *                              logger instance.
    14061484 * @param   fDestFlags          The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
     1485 * @param   pfnPhase            Callback function for starting logging and for ending or starting a new file for log history rotation.
     1486 * @param   cHistory            Number of old log files to keep when performing log history rotation.
     1487 * @param   cbHistoryFileMax    Maximum size of log file when performing history rotation. 0=no size limit.
     1488 * @param   uHistoryTimeSlotLength Maximum time interval per log file when performing history rotation, in seconds. 0=no time limit.
    14071489 * @param   pszErrorMsg         A buffer which is filled with an error message if something fails. May be NULL.
    14081490 * @param   cchErrorMsg         The size of the error message buffer.
     
    14121494RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
    14131495                          const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    1414                           uint32_t fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
     1496                          uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
     1497                          uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
     1498                          char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
    14151499
    14161500/**
     
    14271511 *                              logger instance.
    14281512 * @param   fDestFlags          The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
     1513 * @param   pfnPhase            Callback function for starting logging and for ending or starting a new file for log history rotation.
     1514 * @param   cHistory            Number of old log files to keep when performing log history rotation.
     1515 * @param   cbHistoryFileMax    Maximum size of log file when performing history rotation. 0=no size limit.
     1516 * @param   uHistoryTimeSlotLength Maximum time interval per log file when performing history rotation, in seconds. 0=no time limit.
    14291517 * @param   pszErrorMsg         A buffer which is filled with an error message if something fails. May be NULL.
    14301518 * @param   cchErrorMsg         The size of the error message buffer.
     
    14341522RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
    14351523                           const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    1436                            uint32_t fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
     1524                           uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
     1525                           uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
     1526                           char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
    14371527
    14381528/**
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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