Changeset 69749 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Nov 19, 2017 12:49:36 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/log.cpp
r69746 r69749 228 228 #endif 229 229 #ifdef IN_RING3 230 static int rtR3LogOpenFileDestination(PRTLOGGER pLogger, char *pszErrorMsg, size_t cchErrorMsg);230 static int rtR3LogOpenFileDestination(PRTLOGGER pLogger, PRTERRINFO pErrInfo); 231 231 #endif 232 232 #ifndef IN_RC … … 781 781 uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory, 782 782 uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot, 783 char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args)783 PRTERRINFO pErrInfo, const char *pszFilenameFmt, va_list args) 784 784 { 785 785 int rc; … … 791 791 * Validate input. 792 792 */ 793 if ( 794 || 793 if ( (cGroups && !papszGroups) 794 || !VALID_PTR(ppLogger) ) 795 795 { 796 796 AssertMsgFailed(("Invalid parameters!\n")); … … 798 798 } 799 799 *ppLogger = NULL; 800 801 if (pszErrorMsg)802 RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("unknown error"));803 800 804 801 AssertMsgReturn(cHistory < _1M, ("%#x", cHistory), VERR_OUT_OF_RANGE); … … 882 879 else 883 880 { 881 rc = VERR_NO_MEMORY; 884 882 # ifdef RT_OS_LINUX 885 if (pszErrorMsg)/* Most probably SELinux causing trouble since the larger RTMemAlloc succeeded. */886 RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("mmap(PROT_WRITE | PROT_EXEC) failed -- SELinux?"));883 /* Most probably SELinux causing trouble since the larger RTMemAlloc succeeded. */ 884 RTErrInfoSet(rc, N_("mmap(PROT_WRITE | PROT_EXEC) failed -- SELinux?")); 887 885 # endif 888 rc = VERR_NO_MEMORY;889 886 } 890 887 if (RT_SUCCESS(rc)) … … 948 945 # ifdef IN_RING3 949 946 if ((pLogger->fDestFlags & (RTLOGDEST_FILE | RTLOGDEST_F_DELAY_FILE)) == RTLOGDEST_FILE) 950 rc = rtR3LogOpenFileDestination(pLogger, p szErrorMsg, cchErrorMsg);947 rc = rtR3LogOpenFileDestination(pLogger, pErrInfo); 951 948 # endif 952 949 … … 984 981 } 985 982 986 if (pszErrorMsg) 987 RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("failed to create semaphore")); 983 RTErrInfoSet(pErrInfo, rc, N_("failed to create semaphore")); 988 984 } 989 985 # ifdef IN_RING3 … … 1016 1012 rc = RTLogCreateExV(ppLogger, fFlags, pszGroupSettings, pszEnvVarBase, cGroups, papszGroups, 1017 1013 fDestFlags, NULL /*pfnPhase*/, 0 /*cHistory*/, 0 /*cbHistoryFileMax*/, 0 /*cSecsHistoryTimeSlot*/, 1018 NULL /*p szErrorMsg*/, 0 /*cchErrorMsg*/, pszFilenameFmt, args);1014 NULL /*pErrInfo*/, pszFilenameFmt, args); 1019 1015 va_end(args); 1020 1016 return rc; … … 1027 1023 uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory, 1028 1024 uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot, 1029 char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...)1025 PRTERRINFO pErrInfo, const char *pszFilenameFmt, ...) 1030 1026 { 1031 1027 va_list args; … … 1035 1031 rc = RTLogCreateExV(ppLogger, fFlags, pszGroupSettings, pszEnvVarBase, cGroups, papszGroups, 1036 1032 fDestFlags, pfnPhase, cHistory, cbHistoryFileMax, cSecsHistoryTimeSlot, 1037 p szErrorMsg, cchErrorMsg, pszFilenameFmt, args);1033 pErrInfo, pszFilenameFmt, args); 1038 1034 va_end(args); 1039 1035 return rc; … … 2458 2454 && pLogger->pInt->hFile == NIL_RTFILE) 2459 2455 { 2460 rc = rtR3LogOpenFileDestination(pLogger, NULL, 0);2456 rc = rtR3LogOpenFileDestination(pLogger, pErrInfo); 2461 2457 if (RT_SUCCESS(rc)) 2462 2458 rtlogFlush(pLogger, false /*fNeedSpace*/); … … 3174 3170 * 3175 3171 * @param pLogger The logger instance to update. NULL is not allowed! 3176 * @param pszErrorMsg A buffer which is filled with an error message if 3177 * something fails. May be NULL. 3178 * @param cchErrorMsg The size of the error message buffer. 3179 */ 3180 static int rtlogFileOpen(PRTLOGGER pLogger, char *pszErrorMsg, size_t cchErrorMsg) 3172 * @param pErrInfo Where to return extended error information. 3173 * Optional. 3174 */ 3175 static int rtlogFileOpen(PRTLOGGER pLogger, PRTERRINFO pErrInfo) 3181 3176 { 3182 3177 uint32_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_NONE; … … 3211 3206 { 3212 3207 pLogger->pInt->hFile = NIL_RTFILE; 3213 if (pszErrorMsg) 3214 RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("could not open file '%s' (fOpen=%#x)"), pLogger->pInt->szFilename, fOpen); 3208 RTErrInfoSetF(pErrInfo, rc, N_("could not open file '%s' (fOpen=%#x)"), pLogger->pInt->szFilename, fOpen); 3215 3209 } 3216 3210 return rc; … … 3228 3222 * called from RTLogCreateExV. Prevents pfnPhase from 3229 3223 * being called. 3230 */ 3231 static void rtlogRotate(PRTLOGGER pLogger, uint32_t uTimeSlot, bool fFirst) 3224 * @param pErrInfo Where to return extended error information. Optional. 3225 */ 3226 static void rtlogRotate(PRTLOGGER pLogger, uint32_t uTimeSlot, bool fFirst, PRTERRINFO pErrInfo) 3232 3227 { 3233 3228 /* Suppress rotating empty log files simply because the time elapsed. */ … … 3321 3316 pLogger->pInt->cbHistoryFileWritten = 0; 3322 3317 pLogger->pInt->uHistoryTimeSlotStart = uTimeSlot; 3323 rtlogFileOpen(pLogger, NULL, 0);3318 rtlogFileOpen(pLogger, pErrInfo); 3324 3319 3325 3320 /* … … 3349 3344 * @returns IPRT status code. 3350 3345 * @param pLogger The logger. 3351 * @param p szErrorMsg Where to return error info. Optional.3352 * @param cchErrorMsg Size of @a pszErrorMsg buffer.3353 */ 3354 static int rtR3LogOpenFileDestination(PRTLOGGER pLogger, char *pszErrorMsg, size_t cchErrorMsg)3346 * @param pErrInfo Where to return extended error information. 3347 * Optional. 3348 */ 3349 static int rtR3LogOpenFileDestination(PRTLOGGER pLogger, PRTERRINFO pErrInfo) 3355 3350 { 3356 3351 int rc; 3357 3352 if (pLogger->fFlags & RTLOGFLAGS_APPEND) 3358 3353 { 3359 rc = rtlogFileOpen(pLogger, p szErrorMsg, cchErrorMsg);3354 rc = rtlogFileOpen(pLogger, pErrInfo); 3360 3355 3361 3356 /* Rotate in case of appending to a too big log file, 3362 3357 otherwise this simply doesn't do anything. */ 3363 rtlogRotate(pLogger, 0, true /* fFirst */ );3358 rtlogRotate(pLogger, 0, true /* fFirst */, pErrInfo); 3364 3359 } 3365 3360 else … … 3367 3362 /* Force rotation if it is configured. */ 3368 3363 pLogger->pInt->cbHistoryFileWritten = UINT64_MAX; 3369 rtlogRotate(pLogger, 0, true /* fFirst */ );3364 rtlogRotate(pLogger, 0, true /* fFirst */, pErrInfo); 3370 3365 3371 3366 /* If the file is not open then rotation is not set up. */ … … 3373 3368 { 3374 3369 pLogger->pInt->cbHistoryFileWritten = 0; 3375 rc = rtlogFileOpen(pLogger, p szErrorMsg, cchErrorMsg);3370 rc = rtlogFileOpen(pLogger, pErrInfo); 3376 3371 } 3377 3372 else … … 3481 3476 if ( (pLogger->fDestFlags & RTLOGDEST_FILE) 3482 3477 && pLogger->pInt->cHistory) 3483 rtlogRotate(pLogger, RTTimeProgramSecTS() / pLogger->pInt->cSecsHistoryTimeSlot, false /* fFirst*/);3478 rtlogRotate(pLogger, RTTimeProgramSecTS() / pLogger->pInt->cSecsHistoryTimeSlot, false /*fFirst*/, NULL /*pErrInfo*/); 3484 3479 #endif 3485 3480 }
Note:
See TracChangeset
for help on using the changeset viewer.