示例#1
0
void CPerfLog::Startup()
{
	if (m_bInitialized)
		return;

	// set default log file path
	TCHAR szAppPath[MAX_PATH];
	GetModuleFileName(NULL, szAppPath, MAX_PATH);
	PathRemoveFileSpec(szAppPath);
	CString strDefFilePath = szAppPath;
	strDefFilePath += _T("\\perflog.csv");

	CString strIniFile;
	strIniFile.Format(_T("%spreferences.ini"), thePrefs.GetConfigDir());
	CIni ini(strIniFile, _T("PerfLog"));

	m_eMode = (ELogMode)ini.GetInt(_T("Mode"), None);
	if (m_eMode != None && m_eMode != OneSample && m_eMode != AllSamples)
		m_eMode = None;

	m_dwInterval = MIN2MS(ini.GetInt(_T("Interval"), 5));
	if ((int)m_dwInterval <= 0)
		m_dwInterval = MIN2MS(5);

	m_strFilePath = ini.GetString(_T("File"), strDefFilePath);
	if (m_strFilePath.IsEmpty())
		m_strFilePath = strDefFilePath;

	m_bInitialized = true;

	if (m_eMode == OneSample)
		LogSamples();
}
示例#2
0
void CPerfLog::Startup()
{
	if (m_bInitialized)
		return;

	CIni ini(thePrefs.GetConfigFile(), _T("PerfLog"));

	m_eMode = (ELogMode)ini.GetInt(_T("Mode"), None);
	if (m_eMode != None && m_eMode != OneSample && m_eMode != AllSamples)
		m_eMode = None;
	if (m_eMode != None)
	{
		m_eFileFormat = (ELogFileFormat)ini.GetInt(_T("FileFormat"), CSV);

		// set default log file path
		CString strDefFilePath = thePrefs.GetMuleDirectory(EMULE_CONFIGBASEDIR);
		if (m_eFileFormat == CSV)
			strDefFilePath += _T("perflog.csv");
		else
			strDefFilePath += _T("perflog.mrtg");

		m_strFilePath = ini.GetString(_T("File"), strDefFilePath);
		if (m_strFilePath.IsEmpty())
			m_strFilePath = strDefFilePath;

		if (m_eFileFormat == MRTG)
		{
			TCHAR drv[_MAX_DRIVE];
			TCHAR dir[_MAX_DIR];
			TCHAR nam[_MAX_FNAME];
			_tsplitpath(m_strFilePath, drv, dir, nam, NULL);
			m_strFilePath.Empty();

			_tmakepathlimit(m_strMRTGDataFilePath.GetBuffer(MAX_PATH), drv, dir, CString(nam) + _T("_data"), _T("mrtg"));
			m_strMRTGDataFilePath.ReleaseBuffer();

			_tmakepathlimit(m_strMRTGOverheadFilePath.GetBuffer(MAX_PATH), drv, dir, CString(nam) + _T("_overhead"), _T("mrtg"));
			m_strMRTGOverheadFilePath.ReleaseBuffer();
		}

		m_dwInterval = MIN2MS(ini.GetInt(_T("Interval"), 5));
		if ((int)m_dwInterval <= 0)
			m_dwInterval = MIN2MS(5);
	}

	m_bInitialized = true;

	if (m_eMode == OneSample)
		LogSamples();
}