VirtualBox

Changeset 36408 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 24, 2011 4:25:47 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70763
Message:

log rotation review and adjustments: Don't delete any excess files if log roation is disabled - we don't know what these files might be. Moved RTLOGGERFILE into log.c. Keep RTLogCreate simple, anyone needing rotation can use RTLogCreateEx[V]. Made RTLogGetDestinations produce the log rotation bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/log.h

    r36344 r36408  
    178178    RTLOGPHASE_PREROTATE,
    179179    /** After rotating the log file. */
    180     RTLOGPHASE_POSTROTATE
     180    RTLOGPHASE_POSTROTATE,
     181    /** 32-bit type blow up hack.  */
     182    RTLOGPHASE_32BIT_HACK = 0x7fffffff
    181183} RTLOGPHASE;
    182184
     
    224226 * Log file header/footer callback.
    225227 *
    226  * @param   pLogger     Pointer to the logger instance.
    227  * @param   enmLogPhase Indicates at what time the callback is invoked.
     228 * @param   pLogger         Pointer to the logger instance.
     229 * @param   enmLogPhase     Indicates at what time the callback is invoked.
     230 * @param   pfnLogPhaseMsg  Callback for writing the header/footer (RTLogPrintf
     231 *                          and others are out of bounds).
    228232 */
    229233typedef DECLCALLBACK(void) FNRTLOGPHASE(PRTLOGGER pLogger, RTLOGPHASE enmLogPhase, PFNRTLOGPHASEMSG pfnLogPhaseMsg);
     
    287291#ifndef IN_RC
    288292
    289 #ifdef IN_RING3
    290 /**
    291  * File logging bits for the logger.
    292  */
    293 typedef 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 */
    316 typedef void RTLOGGERFILE;
    317 #endif /* !IN_RING3 */
    318293/** Pointer to file logging bits for the logger. */
    319 typedef RTLOGGERFILE *PRTLOGGERFILE;
     294typedef struct RTLOGGERFILE *PRTLOGGERFILE;
    320295
    321296/**
     
    351326    /** Destination flags - RTLOGDEST. */
    352327    uint32_t                fDestFlags;
    353     /** currently unused field. */
     328    /** Currently unused field. */
    354329    uint32_t                uUnused;
    355330    /** Pointer to the file related logging information.
     
    14501425 *
    14511426 * @param   ppLogger            Where to store the logger instance.
    1452  * @param   fFlags              Logger instance flags, a combination of the RTLOGFLAGS_* values.
     1427 * @param   fFlags              Logger instance flags, a combination of the
     1428 *                              RTLOGFLAGS_* values.
    14531429 * @param   pszGroupSettings    The initial group settings.
    1454  * @param   pszEnvVarBase       Base name for the environment variables for this instance.
     1430 * @param   pszEnvVarBase       Base name for the environment variables for
     1431 *                              this instance.
    14551432 * @param   cGroups             Number of groups in the array.
    1456  * @param   papszGroups         Pointer to array of groups. This must stick around for the life of the
    1457  *                              logger instance.
    1458  * @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.
    1463  * @param   pszFilenameFmt      Log filename format string. Standard RTStrFormat().
     1433 * @param   papszGroups         Pointer to array of groups.  This must stick
     1434 *                              around for the life of the logger instance.
     1435 * @param   fDestFlags          The destination flags.  RTLOGDEST_FILE is ORed
     1436 *                              if pszFilenameFmt specified.
     1437 * @param   pszFilenameFmt      Log filename format string.  Standard
     1438 *                              RTStrFormat().
    14641439 * @param   ...                 Format arguments.
    14651440 */
    14661441RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
    14671442                        const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    1468                         uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
    1469                         uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
    1470                         const char *pszFilenameFmt, ...);
     1443                        uint32_t fDestFlags, const char *pszFilenameFmt, ...);
    14711444
    14721445/**
     
    14761449 *
    14771450 * @param   ppLogger            Where to store the logger instance.
    1478  * @param   fFlags              Logger instance flags, a combination of the RTLOGFLAGS_* values.
     1451 * @param   fFlags              Logger instance flags, a combination of the
     1452 *                              RTLOGFLAGS_* values.
    14791453 * @param   pszGroupSettings    The initial group settings.
    1480  * @param   pszEnvVarBase       Base name for the environment variables for this instance.
     1454 * @param   pszEnvVarBase       Base name for the environment variables for
     1455 *                              this instance.
    14811456 * @param   cGroups             Number of groups in the array.
    1482  * @param   papszGroups         Pointer to array of groups. This must stick around for the life of the
    1483  *                              logger instance.
    1484  * @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.
     1457 * @param   papszGroups         Pointer to array of groups.  This must stick
     1458 *                              around for the life of the logger instance.
     1459 * @param   fDestFlags          The destination flags.  RTLOGDEST_FILE is ORed
     1460 *                              if pszFilenameFmt specified.
     1461 * @param   pfnPhase            Callback function for starting logging and for
     1462 *                              ending or starting a new file for log history
     1463 *                              rotation.  NULL is OK.
     1464 * @param   cHistory            Number of old log files to keep when performing
     1465 *                              log history rotation.  0 means no history.
     1466 * @param   cbHistoryFileMax    Maximum size of log file when performing
     1467 *                              history rotation. 0 means no size limit.
     1468 * @param   cSecsHistoryTimeSlot Maximum time interval per log file when
     1469 *                              performing history rotation, in seconds.
     1470 *                              0 means time limit.
    14891471 * @param   pszErrorMsg         A buffer which is filled with an error message if something fails. May be NULL.
    14901472 * @param   cchErrorMsg         The size of the error message buffer.
     
    14951477                          const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    14961478                          uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
    1497                           uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
     1479                          uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
    14981480                          char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
    14991481
     
    15041486 *
    15051487 * @param   ppLogger            Where to store the logger instance.
    1506  * @param   fFlags              Logger instance flags, a combination of the RTLOGFLAGS_* values.
     1488 * @param   fFlags              Logger instance flags, a combination of the
     1489 *                              RTLOGFLAGS_* values.
    15071490 * @param   pszGroupSettings    The initial group settings.
    1508  * @param   pszEnvVarBase       Base name for the environment variables for this instance.
     1491 * @param   pszEnvVarBase       Base name for the environment variables for
     1492 *                              this instance.
    15091493 * @param   cGroups             Number of groups in the array.
    1510  * @param   papszGroups         Pointer to array of groups. This must stick around for the life of the
    1511  *                              logger instance.
    1512  * @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.
    1517  * @param   pszErrorMsg         A buffer which is filled with an error message if something fails. May be NULL.
     1494 * @param   papszGroups         Pointer to array of groups.  This must stick
     1495 *                              around for the life of the logger instance.
     1496 * @param   fDestFlags          The destination flags.  RTLOGDEST_FILE is ORed
     1497 *                              if pszFilenameFmt specified.
     1498 * @param   pfnPhase            Callback function for starting logging and for
     1499 *                              ending or starting a new file for log history
     1500 *                              rotation.
     1501 * @param   cHistory            Number of old log files to keep when performing
     1502 *                              log history rotation.  0 means no history.
     1503 * @param   cbHistoryFileMax    Maximum size of log file when performing
     1504 *                              history rotation.  0 means no size limit.
     1505 * @param   cSecsHistoryTimeSlot  Maximum time interval per log file when
     1506 *                              performing history rotation, in seconds.
     1507 *                              0 means no time limit.
     1508 * @param   pszErrorMsg         A buffer which is filled with an error message
     1509 *                              if something fails.  May be NULL.
    15181510 * @param   cchErrorMsg         The size of the error message buffer.
    1519  * @param   pszFilenameFmt      Log filename format string. Standard RTStrFormat().
     1511 * @param   pszFilenameFmt      Log filename format string.  Standard
     1512 *                              RTStrFormat().
    15201513 * @param   args                Format arguments.
    15211514 */
     
    15231516                           const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
    15241517                           uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
    1525                            uint64_t cbHistoryFileMax, uint32_t uHistoryTimeSlotLength,
     1518                           uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
    15261519                           char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
    15271520
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