- Timestamp:
- Jun 23, 2009 4:31:12 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48996
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r20835 r20853 183 183 */ 184 184 typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger); 185 /** Pointer to loggerfunction. */185 /** Pointer to flush function. */ 186 186 typedef FNRTLOGFLUSH *PFNRTLOGFLUSH; 187 187 … … 194 194 /** Pointer to logger function. */ 195 195 typedef RCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC; 196 197 /** 198 * Custom log prefix callback. 199 * 200 * 201 * @returns The number of chars written. 202 * 203 * @param pLogger Pointer to the logger instance. 204 * @param pchBuf Output buffer pointer. 205 * No need to terminate the output. 206 * @param cchBuf The size of the output buffer. 207 * @param pvUser The user argument. 208 */ 209 typedef DECLCALLBACK(size_t) FNRTLOGPREFIX(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser); 210 /** Pointer to prefix callback function. */ 211 typedef FNRTLOGPREFIX *PFNRTLOGPREFIX; 212 196 213 197 214 … … 253 270 /** Pointer to the flush function. */ 254 271 PFNRTLOGFLUSH pfnFlush; 272 /** Custom prefix callback. */ 273 PFNRTLOGPREFIX pfnPrefix; 274 /** Prefix callback argument. */ 275 void *pvPrefixUserArg; 255 276 /** Mutex. */ 256 277 RTSEMFASTMUTEX MutexSem; … … 283 304 #define RTLOGGER_MAGIC 0x19281207 284 305 285 #endif 306 #endif /* !IN_RC */ 286 307 287 308 … … 323 344 /** New lines should be prefixed with thread name. */ 324 345 RTLOGFLAGS_PREFIX_THREAD = 0x00800000, 325 /** New lines should be prefixed with the VCPU id. */326 RTLOGFLAGS_PREFIX_ VCPU= 0x01000000,346 /** New lines should be prefixed with data from a custom callback. */ 347 RTLOGFLAGS_PREFIX_CUSTOM = 0x01000000, 327 348 /** New lines should be prefixed with formatted timestamp since program start. */ 328 349 RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000, … … 1403 1424 1404 1425 /** 1426 * Sets the custom prefix callback. 1427 * 1428 * @returns IPRT status code. 1429 * @param pLogger The logger instance. 1430 * @param pfnCallback The callback. 1431 * @param pvUser The user argument for the callback. 1432 * */ 1433 RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger, PFNRTLOGPREFIX pfnCallback, void *pvUser); 1434 1435 /** 1405 1436 * Copies the group settings and flags from logger instance to another. 1406 1437 * -
trunk/src/VBox/Runtime/common/log/log.cpp
r20819 r20853 933 933 rtlogUnlock(pDstLogger); 934 934 } 935 } 936 937 938 /** 939 * Sets the custom prefix callback. 940 * 941 * @returns IPRT status code. 942 * @param pLogger The logger instance. 943 * @param pfnCallback The callback. 944 * @param pvUser The user argument for the callback. 945 * */ 946 RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger, PFNRTLOGPREFIX pfnCallback, void *pvUser) 947 { 948 /* 949 * Resolve defaults. 950 */ 951 if (!pLogger) 952 { 953 pLogger = RTLogDefaultInstance(); 954 if (!pLogger) 955 return VINF_SUCCESS; 956 } 957 AssertReturn(pLogger->u32Magic == RTLOGGER_MAGIC, VERR_INVALID_MAGIC); 958 959 /* 960 * Do the work. 961 */ 962 rtlogLock(pLogger); 963 pLogger->pvPrefixUserArg = pvUser; 964 pLogger->pfnPrefix = pfnCallback; 965 rtlogUnlock(pLogger); 966 967 return VINF_SUCCESS; 935 968 } 936 969 … … 1275 1308 { "tid", sizeof("tid" ) - 1, RTLOGFLAGS_PREFIX_TID, false }, 1276 1309 { "thread", sizeof("thread" ) - 1, RTLOGFLAGS_PREFIX_THREAD, false }, 1310 { "custom", sizeof("custom" ) - 1, RTLOGFLAGS_PREFIX_CUSTOM, false }, 1277 1311 { "timeprog", sizeof("timeprog" ) - 1, RTLOGFLAGS_PREFIX_TIME_PROG, false }, 1278 1312 { "time", sizeof("time" ) - 1, RTLOGFLAGS_PREFIX_TIME, false }, … … 1933 1967 /* 1934 1968 * Flush the buffer if there isn't enough room for the maximum prefix config. 1935 * Max is 2 24, add a couple of extra bytes.1969 * Max is 256, add a couple of extra bytes. 1936 1970 */ 1937 if (cb < 2 24+ 16)1971 if (cb < 256 + 16) 1938 1972 { 1939 1973 rtlogFlush(pLogger); … … 2084 2118 const char *pszName = RTThreadSelfName(); 2085 2119 #elif defined IN_RC 2086 const char *pszName = "EMT- GC";2120 const char *pszName = "EMT-RC"; 2087 2121 #else 2088 const char *pszName = " EMT-R0";2122 const char *pszName = "R0"; 2089 2123 #endif 2090 2124 size_t cch = 0; … … 2110 2144 *psz++ = ' '; /* +17 */ 2111 2145 } 2146 #ifndef IN_RC 2147 if ( (pLogger->fFlags & RTLOGFLAGS_PREFIX_CUSTOM) 2148 && pLogger->pfnPrefix) 2149 { 2150 psz += pLogger->pfnPrefix(pLogger, psz, 31, pLogger->pvPrefixUserArg); 2151 *psz++ = ' '; /* +32 */ 2152 } 2153 #endif 2112 2154 if (pLogger->fFlags & RTLOGFLAGS_PREFIX_LOCK_COUNTS) 2113 2155 {
Note:
See TracChangeset
for help on using the changeset viewer.