Engine
Class StatLogFile

source: C:\XIII\Engine\Classes\StatLogFile.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.StatLog
            |
            +--Engine.StatLogFile
Direct Known Subclasses:None

class StatLogFile
extends Engine.StatLog

//============================================================================= // Logs game events for stat collection // // Logs to a file. //=============================================================================
Variables
 int LogAr
           C++ FArchive*.
 string StatLogFile
           C++ FArchive*.
 string StatLogFinal
           C++ FArchive*.
 bool bWatermark


Function Summary
 void CloseLog()
 void FileFlush()
 void FileLog(string EventString)
 void FlushLog()
 void GetChecksum(out string)
 void LogEventString(string EventString)
 void LogGameEnd(string Reason)
 void LogPlayerConnect(Controller Player, optional string)
 void LogWorldEventString(string EventString)
 void OpenLog()
     
// File Manipulation
 void StartLog()
     
// Logging.
 void StopLog()
 void Watermark(string EventString)



Source Code


00001	//=============================================================================
00002	// Logs game events for stat collection
00003	//
00004	// Logs to a file.
00005	//=============================================================================
00006	class StatLogFile extends StatLog
00007		native;
00008	
00009	var bool bWatermark;
00010	
00011	// Internal
00012	var int LogAr; // C++ FArchive*.
00013	
00014	// Configs
00015	var string StatLogFile;
00016	var string StatLogFinal;
00017	
00018	// File Manipulation
00019	native final function OpenLog();
00020	native final function CloseLog();
00021	native final function Watermark( string EventString );
00022	native final function GetChecksum( out string Checksum );
00023	native final function FileFlush();
00024	native final function FileLog( string EventString );
00025	
00026	// Logging.
00027	function StartLog()
00028	{
00029		local string FileName;
00030		local string AbsoluteTime;
00031	
00032		SaveConfig();
00033	
00034		AbsoluteTime = GetShortAbsoluteTime();
00035		if (!bWorld)
00036		{
00037			FileName = LocalLogDir$"/"$GameName$"."$LocalStandard$"."$AbsoluteTime$"."$Level.Game.GetServerPort();
00038			StatLogFile = FileName$".tmp";
00039			StatLogFinal = FileName$".log";
00040		} 
00041		else 
00042		{
00043			FileName = WorldLogDir$"/"$GameName$"."$WorldStandard$"."$AbsoluteTime$"."$Level.Game.GetServerPort();
00044			StatLogFile = FileName$".tmp";
00045			StatLogFinal = FileName$".log";
00046			bWatermark = True;
00047		}
00048	
00049		OpenLog();
00050	
00051		if ( LocalLog != None )
00052			LocalLog.StartLog();
00053	
00054		LogStandardInfo();
00055		LogServerInfo();
00056		LogMapParameters();
00057	}
00058	
00059	function StopLog()
00060	{
00061		FileFlush();
00062		CloseLog();
00063		if (bBatchLocal)
00064			ExecuteSilentLogBatcher();
00065	
00066		if ( LocalLog != None )
00067			LocalLog.StopLog();
00068	}
00069	
00070	function FlushLog()
00071	{
00072		FileFlush();
00073		if ( LocalLog != None )
00074			LocalLog.FlushLog();
00075	
00076	}
00077	
00078	function LogEventString( string EventString )
00079	{
00080		if( bWatermark )
00081			Watermark( EventString );
00082		FileLog( EventString );
00083		FileFlush();
00084		if ( LocalLog != None )
00085			LocalLog.LogEventString(EventString);
00086	}
00087	
00088	function LogWorldEventString( string EventString )
00089	{
00090		// don't send this event to a local log
00091		if( bWatermark )
00092			Watermark( EventString );
00093		FileLog( EventString );
00094		FileFlush();
00095	}
00096	
00097	// Return a logfile name if relevant.
00098	event string GetLocalLogFileName()
00099	{
00100		if ( bWorld )
00101		{
00102			if (StatLogFile(LocalLog) != None )
00103				return StatLogFile(LocalLog).StatLogFinal;
00104			else
00105				return "";
00106		}
00107		return StatLogFinal;
00108	}
00109	
00110	function LogPlayerConnect(Controller Player, optional string Checksum)
00111	{
00112		if( bWorld )
00113		{
00114			LogEventString( GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Connect"$Chr(9)$Player.PlayerReplicationInfo.PlayerName$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.IsA('Admin')$Chr(9)$Checksum );
00115			LogPlayerInfo( Player );
00116		}
00117		else Super.LogPlayerConnect( Player, Checksum );
00118	}
00119	
00120	function LogGameEnd( string Reason )
00121	{
00122		local string Checksum;
00123	
00124		if( bWorld )
00125		{
00126			bWatermark = False;
00127			GetChecksum( Checksum );
00128			LogEventString(GetTimeStamp()$Chr(9)$"game_end"$Chr(9)$Reason$Chr(9)$Checksum$"");
00129		}
00130		else Super.LogGameEnd(Reason);
00131	}
00132	
00133	defaultproperties
00134	{
00135	     StatLogFile="../Logs/unreal.ngStats.Unknown.log"
00136	}

End Source Code