Changeset 69011 in vbox for trunk/src/VBox/Runtime/common/err
- Timestamp:
- Oct 9, 2017 11:52:45 AM (7 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/err/errinfolog.cpp
r68980 r69011 34 34 #include <iprt/assert.h> 35 35 #include <iprt/string.h> 36 #include <iprt/log.h> 36 37 37 38 38 RTDECL(int) RTErrInfo Set(PRTERRINFO pErrInfo, int rc, const char *pszMsg)39 RTDECL(int) RTErrInfoLogAndSet(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszMsg) 39 40 { 41 /* The logging: */ 42 if (fFlags & RTERRINFO_LOG_F_RELEASE) 43 { 44 PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 45 if (pLogger) 46 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %s\n", rc, pszMsg); 47 } 48 49 PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 50 if (pLogger) 51 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %s\n", rc, pszMsg); 52 53 /* The setting: */ 40 54 if (pErrInfo) 41 55 { … … 51 65 52 66 53 RTDECL(int) RTErrInfo SetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...)67 RTDECL(int) RTErrInfoLogAndSetF(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, ...) 54 68 { 55 69 va_list va; 56 70 va_start(va, pszFormat); 57 RTErrInfo SetV(pErrInfo, rc, pszFormat, va);71 RTErrInfoLogAndSetV(pErrInfo, rc, iLogGroup, fFlags, pszFormat, va); 58 72 va_end(va); 59 73 return rc; … … 61 75 62 76 63 RTDECL(int) RTErrInfo SetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va)77 RTDECL(int) RTErrInfoLogAndSetV(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, va_list va) 64 78 { 79 /* The logging: */ 80 if (fFlags & RTERRINFO_LOG_F_RELEASE) 81 { 82 PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 83 if (pLogger) 84 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %N\n", rc, pszFormat, &va); 85 } 86 87 PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 88 if (pLogger) 89 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %N\n", rc, pszFormat, &va); 90 91 /* The setting: */ 65 92 if (pErrInfo) 66 93 { … … 76 103 77 104 78 RTDECL(int) RTErrInfo Add(PRTERRINFO pErrInfo, int rc, const char *pszMsg)105 RTDECL(int) RTErrInfoLogAndAdd(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszMsg) 79 106 { 80 107 if (pErrInfo) … … 90 117 } 91 118 } 119 120 /* The logging: */ 121 if (fFlags & RTERRINFO_LOG_F_RELEASE) 122 { 123 PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 124 if (pLogger) 125 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %s\n", rc, pszMsg); 126 } 127 128 PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 129 if (pLogger) 130 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %s\n", rc, pszMsg); 131 92 132 return rc; 93 133 } 94 134 95 135 96 RTDECL(int) RTErrInfo AddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...)136 RTDECL(int) RTErrInfoLogAndAddF(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, ...) 97 137 { 98 138 va_list va; 99 139 va_start(va, pszFormat); 100 RTErrInfo AddV(pErrInfo, rc, pszFormat, va);140 RTErrInfoLogAndAddV(pErrInfo, rc, iLogGroup, fFlags, pszFormat, va); 101 141 va_end(va); 102 142 return rc; … … 104 144 105 145 106 RTDECL(int) RTErrInfo AddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va)146 RTDECL(int) RTErrInfoLogAndAddV(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, va_list va) 107 147 { 108 148 if (pErrInfo) … … 114 154 char *pszOut = (char *)memchr(pErrInfo->pszMsg, '\0', pErrInfo->cbMsg - 2); 115 155 if (pszOut) 116 RTStrPrintfV(pszOut, &pErrInfo->pszMsg[pErrInfo->cbMsg] - pszOut, pszFormat, va); 156 { 157 va_list va2; 158 va_copy(va2, va); 159 RTStrPrintfV(pszOut, &pErrInfo->pszMsg[pErrInfo->cbMsg] - pszOut, pszFormat, va2); 160 va_end(va2); 161 } 117 162 } 118 163 else … … 123 168 } 124 169 } 170 171 /* The logging: */ 172 if (fFlags & RTERRINFO_LOG_F_RELEASE) 173 { 174 PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 175 if (pLogger) 176 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %N\n", rc, pszFormat, &va); 177 } 178 179 PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup)); 180 if (pLogger) 181 RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %N\n", rc, pszFormat, &va); 182 125 183 return rc; 126 184 }
Note:
See TracChangeset
for help on using the changeset viewer.