Engine
Class StatLog

source: e:\games\UnrealTournament\Engine\Classes\StatLog.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.StatLog
Direct Known Subclasses:StatLogFile

class StatLog
extends Engine.Info

//============================================================================= // Logs game events for stat collection // // ngLog, ngStats, and ngWorldStats are registered trademarks of // NetGames USA, Inc. at http://www.netgamesusa.com All rights reserved. A // ny and all occurrences of code related to supporting their products and // services appears with their express permission. //=============================================================================
Variables
 int Context
 string DecoderRingURL
           URL to log format decoder ring.
 string GameCreator
           Name of game creator.
 string GameCreatorURL
           URL to info on game creator.
 string GameName
           Name of this game.
 string LocalBatcherParams
           Batcher command line parameters.
 string LocalBatcherURL
           Batcher URL.
 string LocalLogDir
           URL to world stats information.
 string LocalStandard
           The standard this log is compliant to.
 string LocalStatsURL
           URL to local stats information.
 string LogInfoURL
           URL to info on logging standard.
 string LogVersion
           Version of the log standard.
 string WorldBatcherParams
           Batcher command line parameters.
 string WorldBatcherURL
           Batcher URL.
 string WorldLogDir
           URL to world stats information.
 string WorldStandard
           The standard this log is compliant to.
 string WorldStatsURL
           URL to world stats information.
 bool bWorld
 bool bWorldBatcherError
           An error occured last time we tried to process stats.


Function Summary
 void BatchLocal()
 void BeginPlay()
     
// Object
 void BrowseRelativeLocalURL(string URL)
 void ExecuteLocalLogBatcher()
     
// Batching
 void ExecuteSilentLogBatcher()
 void ExecuteWorldLogBatcher()
 void FlushLog()
 string GetAbsoluteTime()
     
// Return absolute time.
 string GetGMTRef()
     
// Time
 string GetLogFileName()
     
// Return a logfile name if relevant.
 string GetMapFileName()
 void GetPlayerChecksum(PlayerPawn P, out string)
 string GetShortAbsoluteTime()
     
// A less verbose version...
 string GetTimeStamp()
     
// Return a timestamp relative to last absolute time.
 void InitialCheck(GameInfo Game)
     
// Special
 void LogEventString(string EventString)
 void LogGameEnd(string Reason)
 void LogGameStart()
 void LogItemActivate(Inventory Item, Pawn Other)
 void LogItemDeactivate(Inventory Item, Pawn Other)
 void LogKill(int KillerID, int VictimID, string KillerWeaponName, string VictimWeaponName, name DamageType)
 void LogMapParameters()
 void LogMutator(Mutator M)
 void LogNameChange(Pawn Other)
 void LogPickup(Inventory Item, Pawn Other)
 void LogPings()
 void LogPlayerConnect(Pawn Player, optional string)
 void LogPlayerDisconnect(Pawn Player)
 void LogPlayerInfo(Pawn Player)
 void LogServerInfo()
 void LogSpecialEvent(string EventType, optional coerce, optional coerce, optional coerce, optional coerce)
 void LogStandardInfo()
     
// Standard Log Entries
 void LogSuicide(Pawn Killed, name DamageType, Pawn Instigator)
 void LogTeamChange(Pawn Other)
 void LogTeamKill(int KillerID, int VictimID, string KillerWeaponName, string VictimWeaponName, name DamageType)
 void LogTypingEvent(bool bTyping, Pawn Other)
 void StartLog()
     
// Logging
 void StopLog()
 void Tick(float Delta)
     
// Track relative timestamps.
 void Timer()



Source Code


00001	//=============================================================================
00002	// Logs game events for stat collection
00003	//
00004	// ngLog, ngStats, and ngWorldStats are registered trademarks of 
00005	// NetGames USA, Inc. at http://www.netgamesusa.com All rights reserved. A
00006	// ny and all occurrences of code related to supporting their products and 
00007	// services appears with their express permission.
00008	//=============================================================================
00009	class StatLog extends Info
00010		native;
00011	
00012	// Internal
00013	var int		Context;
00014	
00015	// State
00016	var bool	bWorld;
00017	
00018	// Time
00019	var	float	TimeStamp;
00020	
00021	// Log Variables
00022	var() string LocalStandard;		// The standard this log is compliant to.
00023	var() string WorldStandard;		// The standard this log is compliant to.
00024	var() string LogVersion;		// Version of the log standard.
00025	var() string LogInfoURL;		// URL to info on logging standard.
00026	var() string GameName;			// Name of this game.
00027	var() string GameCreator;		// Name of game creator.
00028	var() string GameCreatorURL;	// URL to info on game creator.
00029	var() string DecoderRingURL;	// URL to log format decoder ring.
00030	
00031	var() globalconfig string	    LocalBatcherURL;		// Batcher URL.
00032	var() globalconfig string	    LocalBatcherParams;		// Batcher command line parameters.
00033	var() globalconfig string	    LocalStatsURL;			// URL to local stats information.
00034	var() globalconfig string	    WorldBatcherURL;		// Batcher URL.
00035	var() globalconfig string	    WorldBatcherParams;		// Batcher command line parameters.
00036	var() globalconfig string	    WorldStatsURL;			// URL to world stats information.
00037	var() globalconfig string		LocalLogDir;
00038	var() globalconfig string		WorldLogDir;
00039	
00040	var globalconfig bool			bWorldBatcherError;		// An error occured last time we tried to process stats.
00041	
00042	
00043	// Object
00044	function BeginPlay()
00045	{
00046		SetTimer(30.0, True);
00047	}
00048	
00049	function Timer()
00050	{
00051		LogPings();
00052	}
00053	
00054	// Logging
00055	function StartLog()
00056	{
00057		// Implemented in subclass.
00058	}
00059	
00060	function StopLog()
00061	{
00062		// Implemented in subclass.
00063	}
00064	
00065	function FlushLog()
00066	{
00067		// Implemented in subclass.
00068	}
00069	
00070	function LogEventString( string EventString )
00071	{
00072		Log( EventString );
00073	}
00074	
00075	// Batching
00076	native final function ExecuteLocalLogBatcher();
00077	native final function ExecuteSilentLogBatcher();
00078	native final static function BatchLocal();
00079	native final function ExecuteWorldLogBatcher();
00080	native static function BrowseRelativeLocalURL(string URL);
00081	
00082	// Special
00083	native final function InitialCheck( GameInfo Game );
00084	native final function LogMutator( Mutator M );
00085	native static function GetPlayerChecksum( PlayerPawn P, out string Checksum );
00086	
00087	// Time
00088	native final function string GetGMTRef();
00089	
00090	// Return absolute time.
00091	function string GetAbsoluteTime()
00092	{
00093		local string AbsoluteTime;
00094		local string GMTRef;
00095	
00096		AbsoluteTime = string(Level.Year);
00097	
00098		if (Level.Month < 10)
00099			AbsoluteTime = AbsoluteTime$".0"$Level.Month;
00100		else
00101			AbsoluteTime = AbsoluteTime$"."$Level.Month;
00102	
00103		if (Level.Day < 10)
00104			AbsoluteTime = AbsoluteTime$".0"$Level.Day;
00105		else
00106			AbsoluteTime = AbsoluteTime$"."$Level.Day;
00107	
00108		if (Level.Hour < 10)
00109			AbsoluteTime = AbsoluteTime$".0"$Level.Hour;
00110		else
00111			AbsoluteTime = AbsoluteTime$"."$Level.Hour;
00112	
00113		if (Level.Minute < 10)
00114			AbsoluteTime = AbsoluteTime$".0"$Level.Minute;
00115		else
00116			AbsoluteTime = AbsoluteTime$"."$Level.Minute;
00117	
00118		if (Level.Second < 10)
00119			AbsoluteTime = AbsoluteTime$".0"$Level.Second;
00120		else
00121			AbsoluteTime = AbsoluteTime$"."$Level.Second;
00122	
00123		if (Level.Millisecond < 10)
00124			AbsoluteTime = AbsoluteTime$".0"$Level.Millisecond;
00125		else
00126			AbsoluteTime = AbsoluteTime$"."$Level.Millisecond;
00127	
00128		GMTRef = GetGMTRef();
00129	
00130		AbsoluteTime = AbsoluteTime$"."$GMTRef;
00131	
00132		TimeStamp = 0;
00133	
00134		return AbsoluteTime;
00135	}
00136	
00137	// A less verbose version...
00138	function string GetShortAbsoluteTime()
00139	{
00140		local string AbsoluteTime;
00141	
00142		AbsoluteTime = string(Level.Year);
00143	
00144		if (Level.Month < 10)
00145			AbsoluteTime = AbsoluteTime$".0"$Level.Month;
00146		else
00147			AbsoluteTime = AbsoluteTime$"."$Level.Month;
00148	
00149		if (Level.Day < 10)
00150			AbsoluteTime = AbsoluteTime$".0"$Level.Day;
00151		else
00152			AbsoluteTime = AbsoluteTime$"."$Level.Day;
00153	
00154		if (Level.Hour < 10)
00155			AbsoluteTime = AbsoluteTime$".0"$Level.Hour;
00156		else
00157			AbsoluteTime = AbsoluteTime$"."$Level.Hour;
00158	
00159		if (Level.Minute < 10)
00160			AbsoluteTime = AbsoluteTime$".0"$Level.Minute;
00161		else
00162			AbsoluteTime = AbsoluteTime$"."$Level.Minute;
00163	
00164		if (Level.Second < 10)
00165			AbsoluteTime = AbsoluteTime$".0"$Level.Second;
00166		else
00167			AbsoluteTime = AbsoluteTime$"."$Level.Second;
00168	
00169		TimeStamp = 0;
00170	
00171		return AbsoluteTime;
00172	}
00173	
00174	// Return a timestamp relative to last absolute time.
00175	function string GetTimeStamp()
00176	{
00177		local string Time;
00178		local int Pos;
00179	
00180		Time = string(TimeStamp);
00181		Time = Left(Time, InStr(Time, ".") + 3);
00182		return Time;
00183	}
00184	
00185	// Return a logfile name if relevant.
00186	function string GetLogFileName()
00187	{
00188		return "";
00189	}
00190	
00191	// Track relative timestamps.
00192	function Tick(float Delta)
00193	{
00194		TimeStamp += Delta;
00195	}
00196	
00197	// Standard Log Entries
00198	function LogStandardInfo()
00199	{
00200		if (bWorld)
00201			LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Log_Standard"$Chr(9)$WorldStandard);
00202		else
00203			LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Log_Standard"$Chr(9)$LocalStandard);
00204		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Log_Version"$Chr(9)$LogVersion);
00205		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Log_Info_URL"$Chr(9)$LogInfoURL);
00206		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Game_Name"$Chr(9)$GameName);
00207		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Game_Version"$Chr(9)$Level.EngineVersion);
00208		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Game_Creator"$Chr(9)$GameCreator);
00209		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Game_Creator_URL"$Chr(9)$GameCreatorURL);
00210		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Game_Decoder_Ring_URL"$Chr(9)$DecoderRingURL);
00211		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Absolute_Time"$Chr(9)$GetAbsoluteTime());	
00212		if (bWorld)
00213		{
00214			if( Level.ConsoleCommand("get UdpServerUplink douplink") ~= string(true) )
00215				LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_Public"$Chr(9)$"1");
00216			else
00217				LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_Public"$Chr(9)$"0");
00218		}
00219	}
00220	
00221	function LogServerInfo()
00222	{
00223		local string NetworkNumber;
00224	
00225		NetworkNumber = Level.Game.GetNetworkNumber();
00226	
00227		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_ServerName"$Chr(9)$Level.Game.GameReplicationInfo.ServerName);
00228		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_AdminName"$Chr(9)$Level.Game.GameReplicationInfo.AdminName);
00229		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_AdminEmail"$Chr(9)$Level.Game.GameReplicationInfo.AdminEmail);
00230		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_Region"$Chr(9)$Level.Game.GameReplicationInfo.Region);
00231		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_MOTDLine1"$Chr(9)$Level.Game.GameReplicationInfo.MOTDLine1);
00232		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_MOTDLine2"$Chr(9)$Level.Game.GameReplicationInfo.MOTDLine2);
00233		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_MOTDLine3"$Chr(9)$Level.Game.GameReplicationInfo.MOTDLine3);
00234		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_MOTDLine4"$Chr(9)$Level.Game.GameReplicationInfo.MOTDLine4);
00235		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_IP"$Chr(9)$NetworkNumber);
00236		LogEventString(GetTimeStamp()$Chr(9)$"info"$Chr(9)$"Server_Port"$Chr(9)$Level.Game.GetServerPort());
00237	}
00238	
00239	final event LogGameSpecial(String SpecialID, String SpecialParam)
00240	{
00241		LogEventString(GetTimeStamp()$Chr(9)$"game"$Chr(9)$SpecialID$Chr(9)$SpecialParam);
00242	}
00243	
00244	final event LogGameSpecial2(String SpecialID, String SpecialParam, String SpecialParam2)
00245	{
00246		LogEventString(GetTimeStamp()$Chr(9)$"game"$Chr(9)$SpecialID$Chr(9)$SpecialParam$Chr(9)$SpecialParam2);
00247	}
00248	
00249	native final function string GetMapFileName();
00250	
00251	function LogMapParameters()
00252	{
00253		local string MapName;
00254	
00255		MapName = GetMapFileName();
00256	
00257		LogEventString(GetTimeStamp()$Chr(9)$"map"$Chr(9)$"Name"$Chr(9)$MapName);
00258		LogEventString(GetTimeStamp()$Chr(9)$"map"$Chr(9)$"Title"$Chr(9)$Level.Title);
00259		LogEventString(GetTimeStamp()$Chr(9)$"map"$Chr(9)$"Author"$Chr(9)$Level.Author);
00260		LogEventString(GetTimeStamp()$Chr(9)$"map"$Chr(9)$"IdealPlayerCount"$Chr(9)$Level.IdealPlayerCount);
00261		LogEventString(GetTimeStamp()$Chr(9)$"map"$Chr(9)$"LevelEnterText"$Chr(9)$Level.LevelEnterText);
00262	}
00263	
00264	function LogPlayerConnect(Pawn Player, optional string Checksum)
00265	{
00266		if (Player.IsA('PlayerPawn'))
00267			LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Connect"$Chr(9)$Player.PlayerReplicationInfo.PlayerName$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$PlayerPawn(Player).bAdmin);
00268		else
00269			LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Connect"$Chr(9)$Player.PlayerReplicationInfo.PlayerName$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$False);
00270		LogPlayerInfo(Player);
00271	}
00272	
00273	function LogPlayerInfo(Pawn Player)
00274	{
00275		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"TeamName"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.PlayerReplicationInfo.TeamName);
00276		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Team"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.PlayerReplicationInfo.Team);
00277		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"TeamID"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.PlayerReplicationInfo.TeamID);
00278		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Ping"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.PlayerReplicationInfo.Ping);
00279		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"IsABot"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.PlayerReplicationInfo.bIsABot);
00280		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Skill"$Chr(9)$Player.PlayerReplicationInfo.PlayerID$Chr(9)$Player.Skill);
00281	}
00282	
00283	function LogPlayerDisconnect(Pawn Player)
00284	{
00285		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Disconnect"$Chr(9)$Player.PlayerReplicationInfo.PlayerID);
00286	}
00287	
00288	function LogKill( int KillerID, int VictimID, string KillerWeaponName, string VictimWeaponName, name DamageType )
00289	{
00290		LogEventString(GetTimeStamp()$Chr(9)$"kill"$Chr(9)$KillerID$Chr(9)$KillerWeaponName$Chr(9)$VictimID$Chr(9)$VictimWeaponName$Chr(9)$DamageType);
00291	}
00292	
00293	function LogTeamKill( int KillerID, int VictimID, string KillerWeaponName, string VictimWeaponName, name DamageType )
00294	{
00295		LogEventString(GetTimeStamp()$Chr(9)$"teamkill"$Chr(9)$KillerID$Chr(9)$KillerWeaponName$Chr(9)$VictimID$Chr(9)$VictimWeaponName$Chr(9)$DamageType);
00296	}
00297	
00298	function LogSuicide(Pawn Killed, name DamageType, Pawn Instigator)
00299	{
00300		local int KilledID;
00301		local string InstigatorString;
00302	
00303		if (Killed == None)
00304			return;
00305	
00306		KilledID = Killed.PlayerReplicationInfo.PlayerID;
00307		if (Instigator == None)
00308			InstigatorString = "None";
00309		else
00310			InstigatorString = "Self";
00311	
00312		if (Killed.Weapon != None)
00313			LogEventString(GetTimeStamp()$Chr(9)$"suicide"$Chr(9)$KilledID$Chr(9)$Killed.Weapon.ItemName$Chr(9)$DamageType$Chr(9)$InstigatorString);
00314		else
00315			LogEventString(GetTimeStamp()$Chr(9)$"suicide"$Chr(9)$KilledID$Chr(9)$"None"$Chr(9)$DamageType$Chr(9)$InstigatorString);
00316	}
00317	
00318	function LogNameChange(Pawn Other)
00319	{
00320		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Rename"$Chr(9)$Other.PlayerReplicationInfo.PlayerName$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00321	}
00322	
00323	function LogTeamChange(Pawn Other)
00324	{
00325		LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Teamchange"$Chr(9)$Other.PlayerReplicationInfo.PlayerID$Chr(9)$Other.PlayerReplicationInfo.Team);
00326	}
00327	
00328	function LogTypingEvent(bool bTyping, Pawn Other)
00329	{
00330		LogEventString(GetTimeStamp()$Chr(9)$"typing"$Chr(9)$bTyping$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00331	}
00332	
00333	function LogPickup(Inventory Item, Pawn Other)
00334	{
00335		if (Item.ItemName != "")
00336			LogEventString(GetTimeStamp()$Chr(9)$"item_get"$Chr(9)$Item.ItemName$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00337		else
00338			LogEventString(GetTimeStamp()$Chr(9)$"item_get"$Chr(9)$Item.Class$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00339	}
00340	
00341	function LogItemActivate(Inventory Item, Pawn Other)
00342	{
00343		if ( (Other == None) || (Other.PlayerReplicationInfo == None) || (Item == None) )
00344			return;
00345		LogEventString(GetTimeStamp()$Chr(9)$"item_activate"$Chr(9)$Item.ItemName$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00346	}
00347	
00348	function LogItemDeactivate(Inventory Item, Pawn Other)
00349	{
00350		LogEventString(GetTimeStamp()$Chr(9)$"item_deactivate"$Chr(9)$Item.ItemName$Chr(9)$Other.PlayerReplicationInfo.PlayerID);
00351	}
00352	
00353	function LogSpecialEvent(string EventType, optional coerce string Arg1, optional coerce string Arg2, optional coerce string Arg3, optional coerce string Arg4)
00354	{
00355		local string Event;
00356	
00357		Event = EventType;
00358		if (Arg1 != "")
00359			Event = Event$Chr(9)$Arg1;
00360		if (Arg2 != "")
00361			Event = Event$Chr(9)$Arg2;
00362		if (Arg3 != "")
00363			Event = Event$Chr(9)$Arg3;
00364		if (Arg4 != "")
00365			Event = Event$Chr(9)$Arg4;
00366	
00367		LogEventString(GetTimeStamp()$Chr(9)$Event);
00368	}
00369	
00370	function LogPings()
00371	{
00372		local PlayerReplicationInfo PRI;
00373	
00374		foreach AllActors(class'PlayerReplicationInfo', PRI)
00375			LogEventString(GetTimeStamp()$Chr(9)$"player"$Chr(9)$"Ping"$Chr(9)$PRI.PlayerID$Chr(9)$PRI.Ping);
00376	}
00377	
00378	function LogGameStart()
00379	{
00380		LogEventString(GetTimeStamp()$Chr(9)$"game_start");
00381	}
00382	
00383	function LogGameEnd( string Reason )
00384	{
00385		LogEventString(GetTimeStamp()$Chr(9)$"game_end"$Chr(9)$Reason);
00386	}
00387	
00388	defaultproperties
00389	{
00390	     LocalStandard="ngLog"
00391	     WorldStandard="ngLog"
00392	     LogVersion="1.2"
00393	     LogInfoURL="http://www.netgamesusa.com/ngLog/"
00394	     GameName="Unreal"
00395	     GameCreator="Epic MegaGames, Inc."
00396	     GameCreatorURL="http://www.epicgames.com/"
00397	     DecoderRingURL="http://unreal.epicgames.com/Unreal_Log_Decoder_Ring.html"
00398	     LocalBatcherURL="../NetGamesUSA.com/ngStats/ngStatsUT.exe"
00399	     LocalStatsURL="../NetGamesUSA.com/ngStats/html/ngStats_Main.html"
00400	     WorldBatcherURL="../NetGamesUSA.com/ngWorldStats/bin/ngWorldStats.exe"
00401	     WorldBatcherParams="-d ../NetGamesUSA.com/ngWorldStats/logs -g UT"
00402	     WorldStatsURL="http://www.netgamesusa.com"
00403	     LocalLogDir="../Logs"
00404	     WorldLogDir="../NetGamesUSA.com/ngWorldStats/logs"
00405	     bWorldBatcherError=True
00406	}

End Source Code