Files
dsrc/sku.0/sys.server/compiled/game/script/library/trace.scriptlib
T

103 lines
2.3 KiB
Plaintext

// Tracing/Debug library
include java.lang.reflect.*;
include java.lang.Thread.*;
// trace levels
const int TL_DEBUG = 1; // debug gets spammed either to log.txt or DESIGNER_CS_DEBUG_LOG if running on a debug CS log enabled server
const int TL_ERROR_LOG = 2; // -always- writes to log.txt with "ERROR" in the message
const int TL_CS_LOG = 4; // -always- writes to a customer service log
const int TL_WARNING = 8; // -always- writes to log.txt with "WARNING" in the message
const string DESIGNER_CS_DEBUG_LOG = "designer_debug";
//
// default debug log
//
void log(string channel, string message)
{
log(channel, message, null);
}
//
// write a log file either to the designer CS log file if on a test center or write to the standard log.txt file
//
void log(string channel, string message, obj_id logAbout)
{
log(channel, message, logAbout, TL_DEBUG);
}
//
// tests bitmask for flag
//
boolean isFlagSet(int mask, int flag)
{
if((mask & flag) == flag)
{
return true;
}
return false;
}
//
// Writes logs out.
//
void log(string channelOrLogFile, string message, obj_id logAbout, int traceLevelMask)
{
boolean logTxtDone = false;
if(isFlagSet(traceLevelMask, TL_CS_LOG))
{
CustomerServiceLog(channelOrLogFile, message, logAbout);
}
if(isFlagSet(traceLevelMask, TL_ERROR_LOG))
{
LOG(channelOrLogFile, "|ERROR|:[" + logAbout +"]:" + message);
logTxtDone = true;
}
if(isFlagSet(traceLevelMask, TL_WARNING) && (!logTxtDone))
{
LOG(channelOrLogFile, "|WARNING|:[" + logAbout +"]:" + message);
logTxtDone = true;
}
if(isFlagSet(traceLevelMask, TL_DEBUG) && isDebugDefined())
{
if(pipeDebugToCsLog())
{
CustomerServiceLog(DESIGNER_CS_DEBUG_LOG, "[" + channelOrLogFile + "]: " + message, logAbout);
}
else if(!logTxtDone)
{
LOG(channelOrLogFile, "[" + logAbout +"]:" + message);
}
}
return;
}
// checks the server config file to see if the debug trace flag is set.
// this will determine if debugging information will be printed
boolean isDebugDefined()
{
string flag = getConfigSetting("GameServer", "scriptDebugTrace");
if(flag == null || flag.length() < 1)
{
return false;
}
return true;
}
boolean pipeDebugToCsLog()
{
string flag = getConfigSetting("GameServer", "pipeScriptDebugToCsLog");
if(flag == null || flag.length() < 1)
{
return false;
}
return true;
}