예제 #1
0
void RageLog::Write( int where, const RString &sLine )
{
	LockMut( *g_Mutex );

	const char *const sWarningSeparator = "/////////////////////////////////////////";
	vector<RString> asLines;
	split( sLine, "\n", asLines, false );
	if( where & WRITE_LOUD )
	{
		if( m_bLogToDisk && g_fileLog->IsOpen() )
			g_fileLog->PutLine( sWarningSeparator );
		puts( sWarningSeparator );
	}

	RString sTimestamp = SecondsToMMSSMsMsMs( RageTimer::GetTimeSinceStart() ) + ": ";
	RString sWarning;
	if( where & WRITE_LOUD )
		sWarning = "WARNING: ";

	for( unsigned i = 0; i < asLines.size(); ++i )
	{
		RString &sStr = asLines[i];

		if( sWarning.size() )
			sStr.insert( 0, sWarning );

		if( m_bShowLogOutput || (where&WRITE_TO_INFO) )
			puts(sStr); //fputws( (const wchar_t *)sStr.c_str(), stdout );
		if( where & WRITE_TO_INFO )
			AddToInfo( sStr );
		if( m_bLogToDisk && (where&WRITE_TO_INFO) && g_fileInfo->IsOpen() )
			g_fileInfo->PutLine( sStr );
		if( m_bUserLogToDisk && (where&WRITE_TO_USER_LOG) && g_fileUserLog->IsOpen() )
			g_fileUserLog->PutLine( sStr );

		/* Add a timestamp to log.txt and RecentLogs, but not the rest of info.txt
		 * and stdout. */
		sStr.insert( 0, sTimestamp );

		if(where & WRITE_TO_TIME)
			g_fileTimeLog->PutLine(sStr);

		AddToRecentLogs( sStr );
		
		if( m_bLogToDisk && g_fileLog->IsOpen() )
			g_fileLog->PutLine( sStr );
	}

	if( where & WRITE_LOUD )
	{
		if( m_bLogToDisk && g_fileLog->IsOpen() && (where & WRITE_LOUD) )
			g_fileLog->PutLine( sWarningSeparator );
		puts( sWarningSeparator );
	}
	if( m_bFlush || (where & WRITE_TO_INFO) )
		Flush();
}
예제 #2
0
파일: RageLog.cpp 프로젝트: vb-mich/openitg
void RageLog::Write( int where, const CString &line )
{
	LockMut( *g_Mutex );

	vector<CString> lines;
	split( line, "\n", lines, false );
	if( m_bLogToDisk && g_fileLog->IsOpen() && (where & WRITE_LOUD) )
		g_fileLog->PutLine( "/////////////////////////////////////////" );
	if( where & WRITE_LOUD )
		printf( "/////////////////////////////////////////\n" );

	CString sTimestamp = SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()) + ": ";
	CString sWarning;
	if( where & WRITE_LOUD )
		sWarning = "WARNING: ";

	for( unsigned i = 0; i < lines.size(); ++i )
	{
		CString &str = lines[i];

		if( sWarning.size() )
			str.insert( 0, sWarning );

		if( m_bShowLogOutput || where != 0 )
			printf("%s\n", str.c_str() );
		if( where & WRITE_TO_INFO )
			AddToInfo( str );
		if( m_bLogToDisk && where&WRITE_TO_INFO && g_fileInfo->IsOpen() )
			g_fileInfo->PutLine( str );

		/* Add a timestamp to log.txt and RecentLogs, but not the rest of info.txt
		 * and stdout. */
		str.insert( 0, sTimestamp );

		AddToRecentLogs( str );
		
		if( m_bLogToDisk && g_fileLog->IsOpen() )
			g_fileLog->PutLine( str );
	}

	if( m_bLogToDisk && g_fileLog->IsOpen() && (where & WRITE_LOUD) )
		g_fileLog->PutLine( "/////////////////////////////////////////" );
	if( where & WRITE_LOUD )
		printf( "/////////////////////////////////////////\n" );

	if( m_bFlush || (where & WRITE_TO_INFO) )
		Flush();
}