SRL Archive - MSI Suggestions

MSIDebug


Sir R. M8gic1an

2009-09-13 23:34:49


{******************************************************************************}
{ Function MSIDebug(ProcName, TheMessage: string; DebugLevel:integer); }
{ By: Rasta Magician }
{ Rev: 10 }
{ Date: 13 Sep 09 }
{ Description: Used for Debugging. Will debug to DebugBox if }
{ DebugLevel >= Debug_LevelToDebug }
{******************************************************************************}
Function MSIDebug(ProcName, TheMessage: string; DebugLevel:integer);
var
DebugMSG: string;
begin
if DebugLevel < Debug_LevelToDebug then exit;
DebugMSG := TheTime+': ';

try
DebugMSG := DebugMSG + Players[CurrentPlayer].Name+': ';
except end;

case DebugLevel of
//to add some more detail
Debug_PlayerActions: DebugMSG := DebugMSG + 'Player Action: ';
Debug_Functions : DebugMSG := DebugMSG + 'Entering Func: ';
Debug_SmallDetails : DebugMSG := DebugMSG + 'Detail: ';
end;

DebugMSG := DebugMSG + ProcName + ': ';
DebugMSG := DebugMSG + TheMessage;
writeln(DebugMSG);
end;

[php]
{ Debug constants
Description: The several debugging levels, so the user receives as much
detail as he wishes to receive. }
const
Debug_Force = 10; // For MSI SLs to force it to be debuged, not for Script Users!
Debug_Proggie = 7; // Only debug proggie and more important things
Debug_PlayerActions = 5; // Only debug proggie, Player Actions and more important things
Debug_Functions = 3; // Debug the at the start of each function, Player Actions, Proggie and +
Debug_SmallDetails = 1; // Debug small details and more important
Debug_Everything = 0; // For Script Users to have everything in debug box.
[/php]

It's really easy to use :)

MSIDebug('FollowTree', 'Following Tree: '+TreeName, Debug_Functions);

should return:

08:39:35 PM: RMagician: Entering Func: FollowTree: Following Tree: Yew


Be sure to use it often! Use the constants so that you can put more debug on/off for easier finding if something breaks later on.

~RM