Engine
Class StatLog

source: c:\runehov\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


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

End Source Code