123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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);
- }
|