VirtualBox

Changeset 55980 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
May 20, 2015 5:35:22 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100489
Message:

iprt/log.h,++: Added extended logger instance getters that also checks whether the given logger and group-flags are enabled, making the LogRel* checks more efficient in avoid uncessary RTLogLoggerEx parameter building and calls. Ditto for debug logging. The LOG_INSTANCE and LOG_REL_INSTANCE tricks are gone for now.

Location:
trunk/src/VBox/Runtime/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r55436 r55980  
    25762576
    25772577/**
    2578  * Gets the default logger instance, creating it if necessary.
    2579  *
    2580  * @returns Pointer to default logger instance.
    2581  * @returns NULL if no default logger instance available.
    2582  */
    2583 RTDECL(PRTLOGGER)   RTLogDefaultInstance(void)
     2578 * Common worker for RTLogDefaultInstance and RTLogDefaultInstanceEx.
     2579 */
     2580DECL_FORCE_INLINE(PRTLOGGER) rtLogDefaultInstanceCommon(void)
    25842581{
    25852582#ifdef IN_RC
     
    26092606#endif /* !IN_RC */
    26102607}
     2608
     2609
     2610RTDECL(PRTLOGGER)   RTLogDefaultInstance(void)
     2611{
     2612    return rtLogDefaultInstanceCommon();
     2613}
    26112614RT_EXPORT_SYMBOL(RTLogDefaultInstance);
    26122615
    26132616
    2614 /**
    2615  * Gets the default logger instance.
    2616  *
    2617  * @returns Pointer to default logger instance.
    2618  * @returns NULL if no default logger instance available.
    2619  */
    2620 RTDECL(PRTLOGGER)   RTLogGetDefaultInstance(void)
     2617RTDECL(PRTLOGGER)   RTLogDefaultInstanceEx(uint32_t fFlags, uint32_t iGroup)
     2618{
     2619    PRTLOGGER pLogger = rtLogDefaultInstanceCommon();
     2620    if (pLogger)
     2621    {
     2622        if (pLogger->fFlags & RTLOGFLAGS_DISABLED)
     2623            pLogger = NULL;
     2624        else if (   iGroup != UINT32_MAX
     2625                 && (   (pLogger->afGroups[iGroup < pLogger->cGroups ? iGroup : 0] & (fFlags | RTLOGGRPFLAGS_ENABLED))
     2626                     != (fFlags | RTLOGGRPFLAGS_ENABLED)))
     2627            pLogger = NULL;
     2628    }
     2629    return pLogger;
     2630}
     2631RT_EXPORT_SYMBOL(RTLogDefaultInstanceEx);
     2632
     2633
     2634/**
     2635 * Common worker for RTLogGetDefaultInstance and RTLogGetDefaultInstanceEx.
     2636 */
     2637DECL_FORCE_INLINE(PRTLOGGER) rtLogGetDefaultInstanceCommon(void)
    26212638{
    26222639#ifdef IN_RC
     
    26402657#endif
    26412658}
     2659
     2660
     2661RTDECL(PRTLOGGER) RTLogGetDefaultInstance(void)
     2662{
     2663    return rtLogGetDefaultInstanceCommon();
     2664}
    26422665RT_EXPORT_SYMBOL(RTLogGetDefaultInstance);
     2666
     2667
     2668RTDECL(PRTLOGGER) RTLogGetDefaultInstanceEx(uint32_t fFlags, uint32_t iGroup)
     2669{
     2670    PRTLOGGER pLogger = rtLogGetDefaultInstanceCommon();
     2671    if (pLogger)
     2672    {
     2673        if (pLogger->fFlags & RTLOGFLAGS_DISABLED)
     2674            pLogger = NULL;
     2675        else if (   iGroup != UINT32_MAX
     2676                 && (   (pLogger->afGroups[iGroup < pLogger->cGroups ? iGroup : 0] & (fFlags | RTLOGGRPFLAGS_ENABLED))
     2677                     != (fFlags | RTLOGGRPFLAGS_ENABLED)))
     2678            pLogger = NULL;
     2679    }
     2680    return pLogger;
     2681}
     2682RT_EXPORT_SYMBOL(RTLogGetDefaultInstanceEx);
    26432683
    26442684
  • trunk/src/VBox/Runtime/common/log/logrel.cpp

    r48935 r55980  
    7070
    7171
    72 /**
    73  * Gets the default release logger instance.
    74  *
    75  * @returns Pointer to default release logger instance.
    76  * @returns NULL if no default release logger instance available.
    77  */
    78 RTDECL(PRTLOGGER)   RTLogRelDefaultInstance(void)
     72RTDECL(PRTLOGGER)   RTLogRelGetDefaultInstance(void)
    7973{
    8074#ifdef IN_RC
     
    8478#endif /* !IN_RC */
    8579}
    86 RT_EXPORT_SYMBOL(RTLogRelDefaultInstance);
     80RT_EXPORT_SYMBOL(RTLogRelGetDefaultInstance);
     81
     82
     83RTDECL(PRTLOGGER)   RTLogRelGetDefaultInstanceEx(uint32_t fFlags, uint32_t iGroup)
     84{
     85#ifdef IN_RC
     86    PRTLOGGER pLogger = &g_RelLogger;
     87#else /* !IN_RC */
     88    PRTLOGGER pLogger = g_pRelLogger;
     89#endif /* !IN_RC */
     90    if (pLogger)
     91    {
     92        if (pLogger->fFlags & RTLOGFLAGS_DISABLED)
     93            pLogger = NULL;
     94        else if (   iGroup != UINT32_MAX
     95                 && (   (pLogger->afGroups[iGroup < pLogger->cGroups ? iGroup : 0] & (fFlags | RTLOGGRPFLAGS_ENABLED))
     96                     != (fFlags | RTLOGGRPFLAGS_ENABLED)))
     97            pLogger = NULL;
     98    }
     99    return pLogger;
     100}
     101RT_EXPORT_SYMBOL(RTLogRelGetDefaultInstanceEx);
    87102
    88103
     
    123138    if (!pLogger)
    124139    {
    125         pLogger = RTLogRelDefaultInstance();
     140        pLogger = RTLogRelGetDefaultInstance();
    126141        if (!pLogger)
    127142            return;
     
    157172RTDECL(bool) RTLogRelSetBuffering(bool fBuffered)
    158173{
    159     PRTLOGGER pLogger = RTLogRelDefaultInstance();
     174    PRTLOGGER pLogger = RTLogRelGetDefaultInstance();
    160175    if (pLogger)
    161176        return RTLogSetBuffering(pLogger, fBuffered);
  • trunk/src/VBox/Runtime/common/misc/assert.cpp

    r48935 r55980  
    146146# endif
    147147
    148         PRTLOGGER pLog = RTLogRelDefaultInstance();
     148        PRTLOGGER pLog = RTLogRelGetDefaultInstance();
    149149        if (pLog)
    150150        {
     
    255255# endif
    256256
    257         PRTLOGGER pLog = RTLogRelDefaultInstance();
     257        PRTLOGGER pLog = RTLogRelGetDefaultInstance();
    258258        if (pLog)
    259259        {
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