Changeset 41040 in vbox for trunk/src/VBox/Frontends/VBoxBalloonCtrl
- Timestamp:
- Apr 24, 2012 10:13:40 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdog.cpp
r40013 r41040 784 784 } 785 785 786 static void logHeaderFooter(PRTLOGGER pLoggerRelease, RTLOGPHASE enmPhase, PFNRTLOGPHASEMSG pfnLog)787 {788 /* Some introductory information. */789 static RTTIMESPEC s_TimeSpec;790 char szTmp[256];791 if (enmPhase == RTLOGPHASE_BEGIN)792 RTTimeNow(&s_TimeSpec);793 RTTimeSpecToString(&s_TimeSpec, szTmp, sizeof(szTmp));794 795 switch (enmPhase)796 {797 case RTLOGPHASE_BEGIN:798 {799 pfnLog(pLoggerRelease,800 "VirtualBox Watchdog %s r%u %s (%s %s) release log\n"801 #ifdef VBOX_BLEEDING_EDGE802 "EXPERIMENTAL build " VBOX_BLEEDING_EDGE "\n"803 #endif804 "Log opened %s\n",805 VBOX_VERSION_STRING, RTBldCfgRevision(), VBOX_BUILD_TARGET,806 __DATE__, __TIME__, szTmp);807 808 int vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));809 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)810 pfnLog(pLoggerRelease, "OS Product: %s\n", szTmp);811 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));812 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)813 pfnLog(pLoggerRelease, "OS Release: %s\n", szTmp);814 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));815 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)816 pfnLog(pLoggerRelease, "OS Version: %s\n", szTmp);817 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)818 pfnLog(pLoggerRelease, "OS Service Pack: %s\n", szTmp);819 820 /* the package type is interesting for Linux distributions */821 char szExecName[RTPATH_MAX];822 char *pszExecName = RTProcGetExecutablePath(szExecName, sizeof(szExecName));823 pfnLog(pLoggerRelease,824 "Executable: %s\n"825 "Process ID: %u\n"826 "Package type: %s"827 #ifdef VBOX_OSE828 " (OSE)"829 #endif830 "\n",831 pszExecName ? pszExecName : "unknown",832 RTProcSelf(),833 VBOX_PACKAGE_STRING);834 break;835 }836 837 case RTLOGPHASE_PREROTATE:838 pfnLog(pLoggerRelease, "Log rotated - Log started %s\n", szTmp);839 break;840 841 case RTLOGPHASE_POSTROTATE:842 pfnLog(pLoggerRelease, "Log continuation - Log started %s\n", szTmp);843 break;844 845 case RTLOGPHASE_END:846 pfnLog(pLoggerRelease, "End of log file - Log started %s\n", szTmp);847 break;848 849 default:850 /* nothing */;851 }852 }853 854 786 static void displayHeader() 855 787 { … … 1112 1044 displayHeader(); 1113 1045 1114 /* create release logger */ 1115 PRTLOGGER pLoggerRelease; 1116 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 1117 RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG; 1118 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 1119 fFlags |= RTLOGFLAGS_USECRLF; 1120 #endif 1121 char szError[RTPATH_MAX + 128] = ""; 1122 rc = RTLogCreateEx(&pLoggerRelease, fFlags, "all", 1123 "VBOXBALLOONCTRL_RELEASE_LOG", RT_ELEMENTS(s_apszGroups), s_apszGroups, RTLOGDEST_STDOUT, 1124 logHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime, 1125 szError, sizeof(szError), pszLogFile); 1126 if (RT_SUCCESS(rc)) 1127 { 1128 /* register this logger as the release logger */ 1129 RTLogRelSetDefaultInstance(pLoggerRelease); 1130 1131 /* Explicitly flush the log in case of VBOXWEBSRV_RELEASE_LOG=buffered. */ 1132 RTLogFlush(pLoggerRelease); 1133 } 1134 else 1046 /* create release logger, to stdout */ 1047 char szError[RTPATH_MAX + 128]; 1048 rc = com::VBoxLogRelCreate("Watchdog", g_fDaemonize ? NULL : pszLogFile, 1049 RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG, 1050 "all", "VBOXBALLOONCTRL_RELEASE_LOG", 1051 RTLOGDEST_STDOUT, UINT32_MAX /* cMaxEntriesPerGroup */, 1052 g_cHistory, g_uHistoryFileTime, g_uHistoryFileSize, 1053 szError, sizeof(szError)); 1054 if (RT_FAILURE(rc)) 1135 1055 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, rc); 1136 1056 … … 1141 1061 char szLogFile[RTPATH_MAX]; 1142 1062 1143 rc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile)); 1144 if (RT_FAILURE(rc)) 1145 return RTMsgErrorExit(RTEXITCODE_FAILURE, "could not get base directory for logging: %Rrc", rc); 1146 rc = RTPathAppend(szLogFile, sizeof(szLogFile), "vboxballoonctrl.log"); 1147 if (RT_FAILURE(rc)) 1148 return RTMsgErrorExit(RTEXITCODE_FAILURE, "could not construct logging path: %Rrc", rc); 1063 if (!pszLogFile || !*pszLogFile) 1064 { 1065 rc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile)); 1066 if (RT_FAILURE(rc)) 1067 return RTMsgErrorExit(RTEXITCODE_FAILURE, "could not get base directory for logging: %Rrc", rc); 1068 rc = RTPathAppend(szLogFile, sizeof(szLogFile), "vboxballoonctrl.log"); 1069 if (RT_FAILURE(rc)) 1070 return RTMsgErrorExit(RTEXITCODE_FAILURE, "could not construct logging path: %Rrc", rc); 1071 pszLogFile = szLogFile; 1072 } 1149 1073 1150 1074 rc = RTProcDaemonizeUsingFork(false /* fNoChDir */, false /* fNoClose */, pszPidFile); … … 1152 1076 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to daemonize, rc=%Rrc. exiting.", rc); 1153 1077 1154 /* create release logger */ 1155 PRTLOGGER pLoggerReleaseFile; 1156 static const char * const s_apszGroupsFile[] = VBOX_LOGGROUP_NAMES; 1157 RTUINT fFlagsFile = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG; 1158 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 1159 fFlagsFile |= RTLOGFLAGS_USECRLF; 1160 #endif 1161 char szErrorFile[RTPATH_MAX + 128] = ""; 1162 int vrc = RTLogCreateEx(&pLoggerReleaseFile, fFlagsFile, "all", 1163 "VBOXBALLOONCTRL_RELEASE_LOG", RT_ELEMENTS(s_apszGroupsFile), s_apszGroupsFile, RTLOGDEST_FILE, 1164 logHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime, 1165 szErrorFile, sizeof(szErrorFile), szLogFile); 1166 if (RT_SUCCESS(vrc)) 1167 { 1168 /* register this logger as the release logger */ 1169 RTLogRelSetDefaultInstance(pLoggerReleaseFile); 1170 1171 /* Explicitly flush the log in case of VBOXBALLOONCTRL_RELEASE_LOG=buffered. */ 1172 RTLogFlush(pLoggerReleaseFile); 1173 } 1174 else 1175 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szErrorFile, vrc); 1078 /* create release logger, to file */ 1079 rc = com::VBoxLogRelCreate("Watchdog", pszLogFile, 1080 RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG, 1081 "all", "VBOXBALLOONCTRL_RELEASE_LOG", 1082 RTLOGDEST_FILE, UINT32_MAX /* cMaxEntriesPerGroup */, 1083 g_cHistory, g_uHistoryFileTime, g_uHistoryFileSize, 1084 szError, sizeof(szError)); 1085 if (RT_FAILURE(rc)) 1086 return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, rc); 1176 1087 } 1177 1088 #endif
Note:
See TracChangeset
for help on using the changeset viewer.