File size: 4,987 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
typedef Param3<string, string, string> LogTemplate;
typedef int LogTemplateID;
/*
* OBSOLETE: kept for possible backward compatibility only
*/
class LogTemplates
{
static private ref map<LogTemplateID, ref LogTemplate> m_LogTemplates;
static private void RegisterLogTamplate(LogTemplateID template_id, string author, string plugin, string label)
{
if ( m_LogTemplates == NULL )
{
m_LogTemplates = new map<LogTemplateID, ref LogTemplate>;
}
if ( m_LogTemplates.Contains(template_id) )
{
Debug.Log("Template ID: "+string.ToString(template_id)+" is alredy exist!", "LogTemplate.h -> OnInit()", "System", "Template Registration", "None");
}
else
{
LogTemplate params = new LogTemplate(author, plugin, label);
m_LogTemplates.Set(template_id, params);
}
}
// Steps to register of new log template:
// 1.) Crete new LogTemplateID in below of this comment.
// 2.) Set Template Name in format TEMPLATE_[CUSTOM NAME] => TEMPLATE_MY_LOG
// 3.) Set Template ID which is your id + your custom id => + CustomID(0) = 50190
//////////////////////////////////////////////////////////////
// Template Name Template ID
static LogTemplateID TEMPLATE_UNKNOWN = 0;
static LogTemplateID TEMPLATE_JANOSIK = 1;
static LogTemplateID TEMPLATE_PLAYER_WEIGHT = 2;
static LogTemplateID TEMPLATE_BROADCAST = 3;
static void Init()
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////Register Log templates//////////////////////////////////////////////////////////////////////////////////////
// | Template Name | author | plugin | label ////
RegisterLogTamplate( TEMPLATE_UNKNOWN ,"Unknown" ,"Unknown" ,"Unknown" );//
RegisterLogTamplate( TEMPLATE_JANOSIK ,"Janosik" ,"GUI" ,"None" );//
RegisterLogTamplate( TEMPLATE_PLAYER_WEIGHT ,"Unknown" ,"PlayerBase" ,"Weight" );//
RegisterLogTamplate( TEMPLATE_BROADCAST ,"Unknown" ,"PluginMessageManager" ,"Broadcast" );//
}
static LogTemplate GetTemplate(LogTemplateID template_id)
{
if ( m_LogTemplates && m_LogTemplates.Contains(template_id) )
{
return m_LogTemplates.Get(template_id);
}
Debug.Log("Template ID: "+string.ToString(template_id)+" does not exist!", "LogTemplate.h -> GetTemplate()", "System", "Get Log Template", "None");
return NULL;
}
}
/**
\brief Creates debug log (optional) from LogTemplate which are registred
\param template_id \p LogTemplateID ID of LogTemplate which was registred in proto/Logtemplate.h -> "class LogTemplates"
\param message \p string Debug message for log
\return \p void
@code
Log("This is some debug log message", TEMPLATE_JINDRICH);
>> output to scriptExt.log (for GamutLogViewer)
@endcode
*/
void Log(string message, LogTemplateID template_id = 0)
{
LogTemplate log_template = LogTemplates.GetTemplate(template_id);
Debug.Log(message, log_template.param2, log_template.param1, log_template.param3);
}
/**
\brief Creates info log (optional) from LogTemplate which are registred
\param template_id \p LogTemplateID ID of LogTemplate which was registred in proto/Logtemplate.h -> "class LogTemplates"
\param message \p string Info message for log
\return \p void
@code
LogInfo("This is some info log message", TEMPLATE_JINDRICH);
>> output to scriptExt.log (for GamutLogViewer)
@endcode
*/
void LogInfo(string message, LogTemplateID template_id = 0)
{
LogTemplate log_template = LogTemplates.GetTemplate(template_id);
Debug.LogInfo(message, log_template.param2, log_template.param1, log_template.param3);
}
/**
\brief Creates warning log (optional) from LogTemplate which are registred
\param template_id \p LogTemplateID ID of LogTemplate which was registred in proto/Logtemplate.h -> "class LogTemplates"
\param message \p string Warning message for log
\return \p void
@code
LogT(TEMPLATE_JINDRICH, "This is some warning log message");
>> output to scriptExt.log (for GamutLogViewer)
@endcode
*/
void LogWarning(string message, LogTemplateID template_id = 0)
{
LogTemplate log_template = LogTemplates.GetTemplate(template_id);
Debug.LogWarning(message, log_template.param2, log_template.param1, log_template.param3);
}
/**
\brief Creates error log (optional) from LogTemplate which are registred
\param template_id \p LogTemplateID ID of LogTemplate which was registred in proto/Logtemplate.h -> "class LogTemplates"
\param message \p string Error message for log
\return \p void
@code
LogT(TEMPLATE_JINDRICH, "This is some error log message");
>> output to scriptExt.log (for GamutLogViewer)
@endcode
*/
void LogError(string message, LogTemplateID template_id = 0)
{
LogTemplate log_template = LogTemplates.GetTemplate(template_id);
Debug.LogError(message, log_template.param2, log_template.param1, log_template.param3);
}
void SQFPrint(string sqf_msg)
{
Print(sqf_msg);
}
void SQFLog(string sqf_msg)
{
Log(sqf_msg);
} |