Changeset 53778 in vbox for trunk/include/iprt
- Timestamp:
- Jan 12, 2015 9:20:52 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r53173 r53778 1006 1006 1007 1007 1008 /** @def Log It1008 /** @def LogRelIt 1009 1009 * Write to specific logger if group enabled. 1010 */ 1011 /** @def LogRelMaxIt 1012 * Write to specific logger if group enabled and at less than a_cMax messages 1013 * have hit the log. Uses a static variable to count. 1010 1014 */ 1011 1015 #ifdef RTLOG_REL_ENABLED … … 1022 1026 } while (0) 1023 1027 # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) _LogRelIt(a_pvInst, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs) 1028 # define _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, ...) \ 1029 do \ 1030 { \ 1031 PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \ 1032 if ( LogRelIt_pLogger \ 1033 && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \ 1034 { \ 1035 static uint32_t s_LogRelMaxIt_cLogged = 0; \ 1036 if (s_LogRelMaxIt_cLogged < (a_cMax)) \ 1037 { \ 1038 s_LogRelMaxIt_cLogged++; \ 1039 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \ 1040 } \ 1041 } \ 1042 _LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, __VA_ARGS__); \ 1043 } while (0) 1044 # define LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, fmtargs) \ 1045 _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs) 1024 1046 # else 1025 1047 # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) \ … … 1036 1058 LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, fmtargs); \ 1037 1059 } while (0) 1060 # define LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, fmtargs) \ 1061 do \ 1062 { \ 1063 PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \ 1064 if ( LogRelIt_pLogger \ 1065 && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \ 1066 { \ 1067 unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(a_iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(a_iGroup) : 0]; \ 1068 if ((LogIt_fFlags & ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) \ 1069 { \ 1070 static uint32_t s_LogRelMaxIt_cLogged = 0; \ 1071 if (s_LogRelMaxIt_cLogged < (a_cMax)) \ 1072 { \ 1073 s_LogRelMaxIt_cLogged++; \ 1074 LogRelIt_pLogger->pfnLogger fmtargs; \ 1075 } \ 1076 } \ 1077 } \ 1078 LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, fmtargs); \ 1079 } while (0) 1038 1080 # endif 1039 1081 #else /* !RTLOG_REL_ENABLED */ 1040 1082 # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0) 1083 # define LogRelMaxIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0) 1041 1084 # if defined(LOG_USE_C99) 1042 1085 # define _LogRelRemoveParentheseis(...) __VA_ARGS__ 1043 1086 # define _LogRelIt(a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0) 1087 # define _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0) 1044 1088 # endif 1045 1089 #endif /* !RTLOG_REL_ENABLED */ … … 1167 1211 */ 1168 1212 #define LogRelNoName(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a) 1213 1214 1215 /** @def LogRelMax 1216 * Level 1 logging. 1217 */ 1218 #define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a) 1219 1220 /** @def LogRelMax2 1221 * Level 2 logging. 1222 */ 1223 #define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a) 1224 1225 /** @def LogRelMax3 1226 * Level 3 logging. 1227 */ 1228 #define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a) 1229 1230 /** @def LogRelMax4 1231 * Level 4 logging. 1232 */ 1233 #define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a) 1234 1235 /** @def LogRelMax5 1236 * Level 5 logging. 1237 */ 1238 #define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a) 1239 1240 /** @def LogRelMax6 1241 * Level 6 logging. 1242 */ 1243 #define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a) 1244 1245 /** @def LogRelFlow 1246 * Logging of execution flow. 1247 */ 1248 #define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a) 1249 1250 /** @def LogRelMaxFunc 1251 * Release logging. Prepends the given log message with the function name 1252 * followed by a semicolon and space. 1253 */ 1254 #ifdef LOG_USE_C99 1255 # define LogRelMaxFunc(a_cMax, a) \ 1256 _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", \ 1257 __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 1258 # define LogFuncMax(a_cMax, a) \ 1259 _LogItMax(a_cMax, LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", \ 1260 __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 1261 #else 1262 # define LogRelMaxFunc(a_cMax, a) \ 1263 do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0) 1264 #endif 1265 1266 /** @def LogRelMaxThisFunc 1267 * The same as LogRelFunc but for class functions (methods): the resulting log 1268 * line is additionally prepended with a hex value of |this| pointer. 1269 * @param a_cMax Max number of times this should hit the log. 1270 * @param a Log message in format <tt>("string\n" [, args])</tt>. 1271 */ 1272 #ifdef LOG_USE_C99 1273 # define LogRelMaxThisFunc(a_cMax, a) \ 1274 _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", \ 1275 this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 1276 #else 1277 # define LogRelMaxThisFunc(a_cMax, a) \ 1278 do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0) 1279 #endif 1280 1281 /** @def LogRelMaxFlowFunc 1282 * Release logging. Macro to log the execution flow inside C/C++ functions. 1283 * 1284 * Prepends the given log message with the function name followed by 1285 * a semicolon and space. 1286 * 1287 * @param a_cMax Max number of times this should hit the log. 1288 * @param a Log message in format <tt>("string\n" [, args])</tt>. 1289 */ 1290 #ifdef LOG_USE_C99 1291 # define LogRelMaxFlowFunc(a_cMax, a) \ 1292 _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", \ 1293 __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 1294 #else 1295 # define LogRelMaxFlowFunc(a_cMax, a) \ 1296 do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0) 1297 #endif 1169 1298 1170 1299
Note:
See TracChangeset
for help on using the changeset viewer.