Code: Select all
////////////////////////////////////////////////////////////////////////////////
//
// System Name : ALFA Core Scripts
// Filename : _debug_i
// Version : 0.1
// Date : 4/6/06
// Author : Ronan
//
// Local Variable Prefix = COR_DBG_
//
// Description
// These scripts provide tools to configure and run the debugging system.
//
// Revision History
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Includes ////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// For the ArrayInt and ArrayString functions,
#include "nw_o0_itemmaker"
////////////////////////////////////////////////////////////////////////////////
// Constants ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Do not print debug messages anywhere.
const int DEBUG_TARGET_NONE = 0x0000;
// Print debug messages to all DMs.
const int DEBUG_TARGET_DMS = 0x0001;
// Print debug messages to all PCs.
const int DEBUG_TARGET_PCS = 0x0010;
// Print debug messages to logfile.
const int DEBUG_TARGET_LOG = 0x0100;
// Print debug messages to a database.
const int DEBUG_TARGET_DB = 0x1000;
// Signifies a fatal error, keeping the associated system from performing its
// task.
const int DEBUG_LEVEL_FATAL = 1;
// Signifies a non-fatal error or odd behavior, which does not keep the
// associated system from performing its task.
const int DEBUG_LEVEL_WARNING = 2;
// Signifies general debugging information, not any sort of odd behavior or
// error.
const int DEBUG_LEVEL_INFO = 3;
// The prefix of all debug messages by level,
string DEBUG_MESSAGE_PREFIX_FATAL = "ERROR: ";
string DEBUG_MESSAGE_PREFIX_WARNING = "Warning: ";
string DEBUG_MESSAGE_PREFIX_INFO = "";
string LSA_DEBUG_SYSTEMS = "COR_DBG_S_";
string LIA_DEBUG_TARGETS_INFO = "COR_DBG_IT_";
string LIA_DEBUG_TARGETS_WARNING = "COR_DBG_WT_";
string LIA_DEBUG_TARGETS_FATAL = "COR_DBG_FT_";
// The default "catch-all" system for debug messages.
const int DEBUG_SYSTEM_DEFAULT = 0;
const string DEBUG_SYSTEM_DEFAULT_PREFIX = "";
const int DEBUG_SYSTEM_INFO_TARGETS = DEBUG_TARGET_NONE;
const int DEBUG_SYSTEM_WARNING_TARGETS = DEBUG_TARGET_NONE;
const int DEBUG_SYSTEM_FATAL_TARGETS = DEBUG_TARGET_LOG;
////////////////////////////////////////////////////////////////////////////////
// Structures //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Global Variables ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Current number of debugging systems added.
int numSystems;
////////////////////////////////////////////////////////////////////////////////
// Function Prototypes /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// This sends a debug message to the specified target(s).
// Generally PrintDebug() should be used, not this function.
void SendDebugMessage(string message, int targets);
// Prints a debug message from the system id specified with the warning level
// specified. To create a system id, see the CreateDebugSystem() function.
// Valid warning levels are:
//
// DEBUG_LEVEL_FATAL
// Signifies a fatal error, keeping the associated system from performing its
// task.
//
// DEBUG_LEVEL_WARNING
// Signifies a non-fatal error or odd behavior, which does not keep the
// associated system from performing its task.
//
// DEBUG_LEVEL_INFO
// Signifies general debugging information, not any sort of odd behavior or
// error.
void PrintDebugMessage(string message, int systemId = DEBUG_SYSTEM_DEFAULT, int level = DEBUG_LEVEL_INFO);
// Returns a systemId integer which refers to the debugging messages for the
// system.
// prefix is the prefix printed on all debugging messages printed.
// The target parameters are bit-wise variables indicating the places where
// debug messages are sent for each debug warning level (see the
// PrintDebugMessage() function. For example,
// int spawnId = CreateSystemId("Spawn system: ", DEBUG_TARGET_NONE,
// DEBUG_TARGET_LOG,
// DEBUG_TARGET_LOG | DEBUG_TARGET_DMS );
// This call creates a system where no informational messages are printed,
// warning messages go to the log, and fatal errors are sent to all DMs and sent
// to the log. The targets of the three debug levels can be changed in-game by
// a DM-tool as well.
int CreateDebugSystem(string prefix, int infoTargets = DEBUG_TARGET_NONE, int warningTargets = DEBUG_TARGET_LOG, int fatalTargets = DEBUG_TARGET_LOG);
// Initializes the debugging system. This function MUST be called from the
// OnModuleLoad event for the debugging system to function correctly.
void InitializeDebugging();