VirtualBox

Ignore:
Timestamp:
May 20, 2015 5:35:22 PM (10 years ago)
Author:
vboxsync
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.

File:
1 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
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