void mtsIntuitiveResearchKitMTM::EnableLogs(const mtsBool &enable)
{
    logsEnabled = enable;
    if(logsEnabled) // !logsEnabled && enable) //logs previously disabled
    {
        //CMN_LOG_RUN_WARNING << "mtsIntuitiveResearchKitMTM: logs enabled" << std::endl;

        // UBC open output file
        if(!MTMLogFile.is_open())
        {
            std::string fname = componentName;
            fname.append("MTMDebug.log");
            CheckFileExists(&fname);

            MTMLogFile.open(fname.c_str(), std::ofstream::out | std::ofstream::app);
            if(!MTMLogFile.is_open())
                CMN_LOG_CLASS_RUN_WARNING << "Failed to open the MTM log file!" << std::endl;
        }

    }
    else {
        CloseLogs(false);
        //CMN_LOG_RUN_WARNING << "mtsIntuitiveResearchKitMTM: logs disabled" << std::endl;
    }
}
Exemple #2
0
void CLogger::UseClientInterfaces(bool bUse)
{
	if(m_bUseClientInterfaces != bUse)
	{
		wxGetApp().Message(_("Reloading..."));

		wxMutexLocker steamLock(m_steamLock);

		CloseLogs();
		m_bUseClientInterfaces = bUse;
		CleanupSteam();
	}
}
void CLogger::OnIPCFailure(IPCFailure_t* pIPCFailure)
{
	m_hPipe = 0;
	m_hUser = 0;
	m_pSteamClient = NULL;
	m_pSteamFriends = NULL;
	m_pSteamUser = NULL;

	m_pGetChatRoomEntry = NULL;
	m_pGetChatRoomName = NULL;

	CloseLogs();

	wxGetApp().SetTrayIcon(CApp::k_EIconDisconnected, _("Connection to Steam lost"));
	wxGetApp().Warning(_("Connection to Steam lost."));
}
// Description:
//
// Arguments:
//
// Return:
//
void CVisualLog::Reset()
{
	CloseLogs();
	m_bLoggingEnabled = false;
	m_defaultParams = SVisualLogParams();
	m_iFrameId = 0;
	m_eFormat = EVLF_NONE;
	m_sFormat.clear();
	m_sLogBuffer.clear();
	m_sLogParamsBuffer.clear();
	m_sLogFolder.clear();
	m_sLogPath.clear();
	m_iLogFolderNum = 0;
	m_iLogFrameNum = 0;

	m_pCVVisualLog->Set( 0 ); // Turn off logging
}
// Description:
//
// Arguments:
//
// Return:
//
bool CVisualLog::OpenLogs()
{
	m_sFormat = m_pCVVisualLogImageFormat->GetString();
	m_eFormat = GetFormatType( m_sFormat );
	m_sLogFolder = m_pCVVisualLogFolder->GetString();
	int iLogFolderLen = m_sLogFolder.length();

	// Check we have good params to use
	if ( m_eFormat == EVLF_NONE || iLogFolderLen == 0 )
	{
		GameWarning( "[VisualLog] File format or log folder value invalid" );
		return false;
	}

	// Create base directory if necessary
	CryCreateDirectory( m_sLogFolder );

	// Figure out next number in sequence m_sLogFolderName/m_sLogFolderNameXXXX, where XXXX is 0000, 0001, etc.
	int iSeqNum = 0;
	__finddata64_t fd;
	intptr_t handle = _findfirst64( PathUtil::Make( m_sLogFolder , "*.*" ), &fd );
	if ( handle != -1 )
	{
		do 
		{
			// Is it a directory with our base name as a prefix?
			if ( fd.attrib & _A_SUBDIR && fd.name[0]!='.' && 
					 !_strnicmp( m_sLogFolder, fd.name, iLogFolderLen ) )
			{
				iSeqNum = max( iSeqNum, atoi( fd.name + iLogFolderLen ) + 1 );
			}
		}
		while (0 == _findnext64 (handle, &fd));
		_findclose(handle);
	}

	// Now create directory
	char sLogPath[256];
	_snprintf( sLogPath, sizeof(sLogPath), "%s\\%s%04d", m_sLogFolder.c_str(), m_sLogFolder.c_str(), iSeqNum );
	if ( !CryCreateDirectory( sLogPath ) )
	{
		GameWarning( "[VisualLog] Unable to create directory for log files: %s", sLogPath );
		return false;
	}

	m_sLogPath = sLogPath;
	m_iLogFolderNum = iSeqNum;
	
	char sLogFileName[256];
	_snprintf( sLogFileName, sizeof(sLogFileName), "%s\\%s%04d.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum );	
	char sLogParamsFileName[256];
	_snprintf( sLogParamsFileName, sizeof(sLogParamsFileName), "%s\\%s%04d_params.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum );	

	// Open Log Files
	m_fLogFile = fxopen(sLogFileName, "w");
	m_fLogParamsFile = fxopen(sLogParamsFileName, "w");
	if ( !m_fLogFile || !m_fLogParamsFile )
	{
		GameWarning( "[VisualLog] Unable to open log files [%s] [%s]", sLogFileName, sLogParamsFileName );
		CloseLogs();
		return false;
	}

	WriteFileHeaders( sLogFileName, sLogParamsFileName );

	return true;
}
Exemple #6
0
CLogger::~CLogger()
{
	CloseLogs();
	CleanupSteam();
}