Changeset 3086 in vbox
- Timestamp:
- Jun 11, 2007 8:43:47 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r2981 r3086 1087 1087 1088 1088 /** 1089 * Create a logger instance. 1090 * 1091 * @returns iprt status code. 1092 * 1093 * @param ppLogger Where to store the logger instance. 1094 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values. 1095 * @param pszGroupSettings The initial group settings. 1096 * @param pszEnvVarBase Base name for the environment variables for this instance. 1097 * @param cGroups Number of groups in the array. 1098 * @param papszGroups Pointer to array of groups. This must stick around for the life of the 1099 * logger instance. 1100 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified. 1101 * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL. 1102 * @param cchErrorMsg The size of the error message buffer. 1103 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat(). 1104 * @param ... Format arguments. 1105 */ 1106 RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings, 1107 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups, 1108 RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...); 1109 1110 /** 1111 * Create a logger instance. 1112 * 1113 * @returns iprt status code. 1114 * 1115 * @param ppLogger Where to store the logger instance. 1116 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values. 1117 * @param pszGroupSettings The initial group settings. 1118 * @param pszEnvVarBase Base name for the environment variables for this instance. 1119 * @param cGroups Number of groups in the array. 1120 * @param papszGroups Pointer to array of groups. This must stick around for the life of the 1121 * logger instance. 1122 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified. 1123 * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL. 1124 * @param cchErrorMsg The size of the error message buffer. 1125 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat(). 1126 * @param args Format arguments. 1127 */ 1128 RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings, 1129 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups, 1130 RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args); 1131 1132 /** 1089 1133 * Create a logger instance for singled threaded ring-0 usage. 1090 1134 * -
trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
r2981 r3086 935 935 { 936 936 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 937 static char szError[RTPATH_MAX + 128] = ""; 937 938 PRTLOGGER pLogger; 938 rc2 = RTLogCreate (&pLogger, RTLOGFLAGS_PREFIX_TIME_PROG, "all",939 "VBOX_RELEASE_LOG", ELEMENTS(s_apszGroups), s_apszGroups,940 RTLOGDEST_FILE, "./VBoxBFE.log");939 rc2 = RTLogCreateEx(&pLogger, RTLOGFLAGS_PREFIX_TIME_PROG, "all", 940 "VBOX_RELEASE_LOG", ELEMENTS(s_apszGroups), s_apszGroups, 941 RTLOGDEST_FILE, szError, sizeof(szError), "./VBoxBFE.log"); 941 942 if (VBOX_SUCCESS(rc2)) 942 943 { … … 954 955 RTLogRelSetDefaultInstance(pLogger); 955 956 } 957 else 958 RTPrintf("Could not open release log (%s)\n", szError); 956 959 } 957 960 -
trunk/src/VBox/Main/ConsoleImpl.cpp
r3045 r3086 6555 6555 fFlags |= RTLOGFLAGS_USECRLF; 6556 6556 #endif /* __WIN__ */ 6557 vrc = RTLogCreate(&loggerRelease, fFlags, "all", 6558 "VBOX_RELEASE_LOG", ELEMENTS(s_apszGroups), s_apszGroups, 6559 RTLOGDEST_FILE, logFile.raw()); 6557 char szError[RTPATH_MAX + 128] = ""; 6558 vrc = RTLogCreateEx(&loggerRelease, fFlags, "all", 6559 "VBOX_RELEASE_LOG", ELEMENTS(s_apszGroups), s_apszGroups, 6560 RTLOGDEST_FILE, szError, sizeof(szError), logFile.raw()); 6560 6561 if (VBOX_SUCCESS(vrc)) 6561 6562 { … … 6576 6577 { 6577 6578 hrc = setError (E_FAIL, 6578 tr ("Failed to open release log file '%s' (%Vrc)"), 6579 logFile.raw(), vrc); 6579 tr ("Failed to open release log (%s, %Vrc)"), szError, vrc); 6580 6580 break; 6581 6581 } -
trunk/src/VBox/Runtime/log.cpp
r2981 r3086 165 165 #ifndef IN_GC 166 166 /** 167 * Create a logger instance .167 * Create a logger instance, comprehensive version. 168 168 * 169 169 * @returns iprt status code. … … 177 177 * logger instance. 178 178 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified. 179 * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL. 180 * @param cchErrorMsg The size of the error message buffer. 179 181 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat(). 180 182 * @param ... Format arguments. 181 183 */ 182 RTDECL(int) RTLogCreate (PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,183 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,184 RTUINT fDestFlags, const char *pszFilenameFmt, ...)184 RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings, 185 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups, 186 RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args) 185 187 { 186 188 /* … … 250 252 if (pszFilenameFmt) 251 253 { 252 va_list args;253 va_start(args, pszFilenameFmt);254 254 RTStrPrintfV(pLogger->pszFilename, RTPATH_MAX, pszFilenameFmt, args); 255 va_end(args);256 255 pLogger->fDestFlags |= RTLOGDEST_FILE; 257 256 } … … 398 397 #ifdef IN_RING3 399 398 if (pLogger->fDestFlags & RTLOGDEST_FILE) 399 { 400 400 rc = RTFileOpen(&pLogger->File, pLogger->pszFilename, 401 401 RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE); 402 if (RT_FAILURE(rc)) 403 RTStrPrintf(pszErrorMsg, cchErrorMsg, "could not open file '%s'", pLogger->pszFilename); 404 } 402 405 #endif /* IN_RING3 */ 403 406 … … 413 416 return VINF_SUCCESS; 414 417 } 418 else 419 RTStrPrintf(pszErrorMsg, cchErrorMsg, "failed to create sempahore"); 415 420 } 416 421 #ifdef IN_RING3 … … 429 434 } 430 435 436 /** 437 * Create a logger instance. 438 * 439 * @returns iprt status code. 440 * 441 * @param ppLogger Where to store the logger instance. 442 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values. 443 * @param pszGroupSettings The initial group settings. 444 * @param pszEnvVarBase Base name for the environment variables for this instance. 445 * @param cGroups Number of groups in the array. 446 * @param papszGroups Pointer to array of groups. This must stick around for the life of the 447 * logger instance. 448 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified. 449 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat(). 450 * @param ... Format arguments. 451 */ 452 RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings, 453 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups, 454 RTUINT fDestFlags, const char *pszFilenameFmt, ...) 455 { 456 va_list args; 457 int rc; 458 459 va_start(args, pszFilenameFmt); 460 rc = RTLogCreateExV(ppLogger, fFlags, pszGroupSettings, pszEnvVarBase, cGroups, papszGroups, fDestFlags, NULL, 0, pszFilenameFmt, args); 461 va_end(args); 462 return rc; 463 } 464 465 /** 466 * Create a logger instance. 467 * 468 * @returns iprt status code. 469 * 470 * @param ppLogger Where to store the logger instance. 471 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values. 472 * @param pszGroupSettings The initial group settings. 473 * @param pszEnvVarBase Base name for the environment variables for this instance. 474 * @param cGroups Number of groups in the array. 475 * @param papszGroups Pointer to array of groups. This must stick around for the life of the 476 * logger instance. 477 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified. 478 * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL. 479 * @param cchErrorMsg The size of the error message buffer. 480 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat(). 481 * @param ... Format arguments. 482 */ 483 RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings, 484 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups, 485 RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...) 486 { 487 va_list args; 488 int rc; 489 490 va_start(args, pszFilenameFmt); 491 rc = RTLogCreateExV(ppLogger, fFlags, pszGroupSettings, pszEnvVarBase, cGroups, papszGroups, fDestFlags, pszErrorMsg, cchErrorMsg, pszFilenameFmt, args); 492 va_end(args); 493 return rc; 494 } 431 495 432 496 /**
Note:
See TracChangeset
for help on using the changeset viewer.