Changeset 60:f0a7e60638ae in rrlib_logging


Ignore:
Timestamp:
23.08.2011 15:16:18 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Rebase:
38656338373439383837633437363462646534376562346261313065623131313338643862366263
Message:

Added new print and printf macros. RRLIB_LOG_MESSAGE and RRLIB_LOG_STREAM are deprecated from now on and will vanish after some undefined grace period

File:
1 edited

Legend:

Unmodified
Added
Removed
  • definitions.h

    r57 r60  
    107107#define RRLIB_LOG_GET_DOMAIN_I(domain...) \ 
    108108  rrlib::logging::GetLogDomain(RRLIB_DEFAULT_LOG_DOMAIN_NAME, ## domain) \ 
    109     
     109 
    110110#define RRLIB_LOG_GET_DOMAIN(domain, args...) \ 
    111111  RRLIB_LOG_GET_DOMAIN_I(domain) 
     
    113113#define RRLIB_LOG_STREAM_CALL(level, args...) \ 
    114114  ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level)) \ 
    115     
     115 
    116116#define RRLIB_LOG_STREAM_CALL_STATIC(level, args...) \ 
    117117  ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel() ? RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args) : RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level)) \ 
    118     
    119 #define RRLIB_LOG_MESSAGE_CALL(level, args...) \ 
     118 
     119#define RRLIB_LOG_PRINT_CALL(level, args...) \ 
    120120  do \ 
    121121  { \ 
    122122    if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
    123123    { \ 
     124      RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
     125    } \ 
     126  } while (0) \ 
     127 
     128#define RRLIB_LOG_PRINT_CALL_STATIC(level, args...) \ 
     129  do \ 
     130  { \ 
     131    if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
     132    { \ 
     133      RRLIB_LOG_GET_DOMAIN(args)->GetMessageStream("<static>", __FUNCTION__, __FILE__, __LINE__, level).Evaluate(args); \ 
     134    } \ 
     135  } while (0) \ 
     136 
     137#define RRLIB_LOG_PRINTF_CALL(level, args...) \ 
     138  do \ 
     139  { \ 
     140    if ((level) <= RRLIB_LOG_GET_DOMAIN(args)->GetMaxMessageLevel()) \ 
     141    { \ 
    124142      RRLIB_LOG_GET_DOMAIN(args)->PrintMessage(GetLogDescription(), __FUNCTION__, __FILE__, __LINE__, level, args); \ 
    125143    } \ 
    126144  } while (0) \ 
    127       
    128 #define RRLIB_LOG_MESSAGE_CALL_STATIC(level, args...) \ 
     145 
     146#define RRLIB_LOG_PRINTF_CALL_STATIC(level, args...) \ 
    129147  do \ 
    130148  { \ 
     
    134152    } \ 
    135153  } while (0) \ 
    136       
     154 
    137155//---------------------------------------------------------------------- 
    138156// The macro interface to the logging library 
     
    149167#define RRLIB_LOG_STREAM(level, args...) \ 
    150168  RRLIB_LOG_STREAM_CALL(level, args) \ 
    151     
     169 
     170#define RRLIB_LOG_PRINT(level, args...) \ 
     171    do \ 
     172    { \ 
     173      if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     174      { \ 
     175        RRLIB_LOG_PRINT_CALL(level, args); \ 
     176      } \ 
     177    } while (0) \ 
     178 
    152179/*! Macro to get a stream for messages using operator << from static context 
    153180 * 
     
    159186#define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    160187  RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    161     
     188 
     189#define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
     190    do \ 
     191    { \ 
     192      if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     193      { \ 
     194        RRLIB_LOG_PRINT_CALL(level, args); \ 
     195      } \ 
     196    } while (0) \ 
     197 
    162198/*! Macro for messages using printf syntax 
    163199 * 
     
    171207    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    172208    { \ 
    173       RRLIB_LOG_MESSAGE_CALL(level, args); \ 
    174     } \ 
    175   } while (0) \ 
    176       
     209      RRLIB_LOG_PRINTF_CALL(level, args); \ 
     210    } \ 
     211  } while (0) \ 
     212 
     213#define RRLIB_LOG_PRINTF(level, args...) \ 
     214  do \ 
     215  { \ 
     216    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     217    { \ 
     218      RRLIB_LOG_PRINTF_CALL(level, args); \ 
     219    } \ 
     220  } while (0) \ 
     221 
    177222/*! Macro for messages using printf syntax from static context 
    178223 * 
     
    186231    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
    187232    { \ 
    188       RRLIB_LOG_MESSAGE_CALL_STATIC(level, args); \ 
    189     } \ 
    190   } while (0) \ 
    191       
     233      RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
     234    } \ 
     235  } while (0) \ 
     236 
     237#define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
     238  do \ 
     239  { \ 
     240    if ((level) <= rrlib::logging::eLL_DEBUG) \ 
     241    { \ 
     242      RRLIB_LOG_PRINTF_CALL_STATIC(level, args); \ 
     243    } \ 
     244  } while (0) \ 
     245 
    192246#else 
    193247 
     
    201255#define RRLIB_LOG_STREAM(level, args...) \ 
    202256  RRLIB_LOG_STREAM_CALL(level, args) \ 
    203     
     257 
     258#define RRLIB_LOG_PRINT(level, args...) \ 
     259  RRLIB_LOG_PRINT_CALL(level, args) \ 
     260 
    204261/*! Macro to get a stream for messages using operator << from static context 
    205262 * 
     
    211268#define RRLIB_LOG_STREAM_STATIC(level, args...) \ 
    212269  RRLIB_LOG_STREAM_CALL_STATIC(level, args) \ 
    213     
     270 
     271#define RRLIB_LOG_PRINT_STATIC(level, args...) \ 
     272  RRLIB_LOG_PRINT_CALL_STATIC(level, args) \ 
     273 
    214274/*! Macro for messages using printf syntax 
    215275 * 
     
    219279 */ 
    220280#define RRLIB_LOG_MESSAGE(level, args...) \ 
    221   RRLIB_LOG_MESSAGE_CALL(level, args) \ 
    222     
     281  RRLIB_LOG_PRINTF_CALL(level, args) \ 
     282 
     283#define RRLIB_LOG_PRINTF(level, args...) \ 
     284  RRLIB_LOG_PRINTF_CALL(level, args) \ 
     285 
    223286/*! Macro for messages using printf syntax from static context 
    224287 * 
     
    228291 */ 
    229292#define RRLIB_LOG_MESSAGE_STATIC(level, args...) \ 
    230   RRLIB_LOG_MESSAGE_CALL_STATIC(level, args) \ 
    231     
     293  RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
     294 
     295#define RRLIB_LOG_PRINTF_STATIC(level, args...) \ 
     296  RRLIB_LOG_PRINTF_CALL_STATIC(level, args) \ 
     297 
    232298#endif 
    233299 
     
    257323    return default_log_struct::GetDomain(); \ 
    258324  } \ 
    259     
     325 
    260326/*! Macro for creation of a new named domain for the current scope 
    261327 * 
     
    289355    return symbolic_name ## _struct::GetDomain(); \ 
    290356  } \ 
    291     
     357 
    292358 
    293359#endif 
Note: See TracChangeset for help on using the changeset viewer.