DayZ 1.24
Loading...
Searching...
No Matches
DebugPrint Class Reference
Collaboration diagram for DebugPrint:
[legend]

Static Private Member Functions

static void OnInit ()
 
static void Log (string msg)
 Prints debug message with normal prio.
 
static void LogAndTrace (string msg)
 Prints debug message as normal message and prints stack trace of calls.
 
static void LogWarning (string msg)
 Prints debug message as warning message.
 
static void LogWarningAndTrace (string msg)
 Prints debug message as warning message and prints stack trace of calls.
 
static void LogError (string msg)
 Prints debug message as error message.
 
static void LogErrorAndTrace (string msg)
 Prints debug message as error message and prints stack trace of calls.
 
static string AdjustDebugLog (string msg)
 Function adjust received message for debug console (Do not use)
 
static void EnableTracingLogs (bool enable)
 
bool IsDebugLog (string msg)
 
string TrimDebugLog (string msg)
 
bool IsStackTrace (string msg)
 
string TrimStackTrace (string msg)
 
void LogMessage (string msg, int msg_type, bool trace=false)
 

Static Private Attributes

const int MSG_LOG = 0
 
const int MSG_WARNING = 1
 
const int MSG_ERROR = 2
 
const int MSG_COUNT = 3
 
string s_MsgPrefix [MSG_COUNT]
 
string s_MsgStackMarkStart
 
string s_MsgStackMarkEnd
 
bool s_MsgStackMarked
 
bool s_TraceAllLogs
 

Detailed Description

Definition at line 1 of file DebugPrint.c.

Member Function Documentation

◆ AdjustDebugLog()

static string DebugPrint::AdjustDebugLog ( string msg)
inlinestaticprivate

Function adjust received message for debug console (Do not use)

Parameters
msgstring Message for adjust
Returns
string Adjusted Message
string msg = DebugPrint.AdjustDebugLog("s = 'Hello World, this is error log'");
static void Log(string msg)
Prints debug message with normal prio.
Definition DebugPrint.c:37
static string AdjustDebugLog(string msg)
Function adjust received message for debug console (Do not use)
Definition DebugPrint.c:141
Definition World.c:2

Definition at line 141 of file DebugPrint.c.

142 {
143 if (IsStackTrace(msg))
144 return TrimStackTrace(msg);
145
146 if (IsDebugLog(msg))
147 return TrimDebugLog(msg);
148
149 return msg;
150 }
bool IsStackTrace(string msg)
Definition DebugPrint.c:179
bool IsDebugLog(string msg)
Definition DebugPrint.c:157
string TrimStackTrace(string msg)
Definition DebugPrint.c:198
string TrimDebugLog(string msg)
Definition DebugPrint.c:167

References IsDebugLog(), IsStackTrace(), TrimDebugLog(), and TrimStackTrace().

◆ EnableTracingLogs()

static void DebugPrint::EnableTracingLogs ( bool enable)
inlinestaticprivate

Definition at line 152 of file DebugPrint.c.

153 {
155 }
bool s_TraceAllLogs
Definition DebugPrint.c:12

References s_TraceAllLogs.

◆ IsDebugLog()

bool DebugPrint::IsDebugLog ( string msg)
inlinestaticprivate

Definition at line 157 of file DebugPrint.c.

158 {
159 for (int i = 0; i < MSG_COUNT; ++i)
160 {
161 if (msg.IndexOf(s_MsgPrefix[i]) != -1)
162 return true;
163 }
164
165 return false;
166 }
string s_MsgPrefix[MSG_COUNT]
Definition DebugPrint.c:8
const int MSG_COUNT
Definition DebugPrint.c:6

References MSG_COUNT, and s_MsgPrefix.

Referenced by AdjustDebugLog().

◆ IsStackTrace()

bool DebugPrint::IsStackTrace ( string msg)
inlinestaticprivate

Definition at line 179 of file DebugPrint.c.

180 {
181 if (s_MsgStackMarked && msg.IndexOf(s_MsgStackMarkEnd) != -1)
182 {
183 s_MsgStackMarked = false;
184 return false;
185 }
186
188 return true;
189
190 if (msg.IndexOf(s_MsgStackMarkStart) != -1)
191 {
192 s_MsgStackMarked = true;
193 return true;
194 }
195
196 return false;
197 }
bool s_MsgStackMarked
Definition DebugPrint.c:11
string s_MsgStackMarkEnd
Definition DebugPrint.c:10
string s_MsgStackMarkStart
Definition DebugPrint.c:9

References s_MsgStackMarked, s_MsgStackMarkEnd, and s_MsgStackMarkStart.

Referenced by AdjustDebugLog().

◆ Log()

static void DebugPrint::Log ( string msg)
inlinestaticprivate

Prints debug message with normal prio.

Parameters
msgstring Debug message for print
Returns
void None
DebugPrint.Log("Hello World");
>> [Log]: Hello World;

Definition at line 37 of file DebugPrint.c.

38 {
40 }
const int MSG_LOG
Definition DebugPrint.c:3
void LogMessage(string msg, int msg_type, bool trace=false)
Definition DebugPrint.c:206

References LogMessage(), MSG_LOG, and s_TraceAllLogs.

◆ LogAndTrace()

static void DebugPrint::LogAndTrace ( string msg)
inlinestaticprivate

Prints debug message as normal message and prints stack trace of calls.

Parameters
msgstring Debug message for print
Returns
void None
DebugPrint.LogAndTrace("Hello World, this is normal log");
>> [Log]: Hello World, this is normal log
>> -- Stack trace --
>> OnKeyPress() Scripts/mission/missionGameplay.c : 230
>> OnKeyPress() Scripts/DayZGame.c : 346
>> -----------------
Mission mission
static void LogAndTrace(string msg)
Prints debug message as normal message and prints stack trace of calls.
Definition DebugPrint.c:56

Definition at line 56 of file DebugPrint.c.

57 {
58 LogMessage(msg, MSG_LOG, true);
59 }

References LogMessage(), and MSG_LOG.

◆ LogError()

static void DebugPrint::LogError ( string msg)
inlinestaticprivate

Prints debug message as error message.

Parameters
msgstring Debug message for error print
Returns
void None
DebugPrint.LogError("Hello World, this is error log");
>> [Error]: Hello World, this is error log
static void LogError(string msg)
Prints debug message as error message.
Definition DebugPrint.c:105
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

Definition at line 105 of file DebugPrint.c.

106 {
108 }
const int MSG_ERROR
Definition DebugPrint.c:5

References LogMessage(), MSG_ERROR, and s_TraceAllLogs.

◆ LogErrorAndTrace()

static void DebugPrint::LogErrorAndTrace ( string msg)
inlinestaticprivate

Prints debug message as error message and prints stack trace of calls.

Parameters
msgstring Debug message for error print
Returns
void None
DebugPrint.LogErrorAndTrace("Hello World, this is error log");
>> [Error]: Hello World, this is error log
>> -- Stack trace --
>> OnKeyPress() Scripts/mission/missionGameplay.c : 230
>> OnKeyPress() Scripts/DayZGame.c : 346
>> -----------------
static void LogErrorAndTrace(string msg)
Prints debug message as error message and prints stack trace of calls.
Definition DebugPrint.c:124

Definition at line 124 of file DebugPrint.c.

125 {
126 LogMessage(msg, MSG_ERROR, true);
127 }

References LogMessage(), and MSG_ERROR.

Referenced by OnlineServices::ErrorCaught(), OnlineServices::LoadFriends(), OnlineServices::LoadMPPrivilege(), OnlineServices::LoadPermissions(), OnlineServices::LoadServers(), OnlineServices::LoadVoicePrivilege(), OnlineServices::SetServerFavorited(), OnlineServices::ShowInviteScreen(), and OnlineServices::ShowUserProfile().

◆ LogMessage()

void DebugPrint::LogMessage ( string msg,
int msg_type,
bool trace = false )
inlinestaticprivate

Definition at line 206 of file DebugPrint.c.

207 {
208 string mesg = "[" + s_MsgPrefix[msg_type] + "]: " + msg;
209
210 Print(mesg);
211
212 if (trace)
213 DumpStack();
214 }
proto void DumpStack()
Prints current call stack (stack trace)
proto void Print(void var)
Prints content of variable to console/log.

References DumpStack(), Print(), and s_MsgPrefix.

Referenced by Log(), LogAndTrace(), LogError(), LogErrorAndTrace(), LogWarning(), and LogWarningAndTrace().

◆ LogWarning()

static void DebugPrint::LogWarning ( string msg)
inlinestaticprivate

Prints debug message as warning message.

Parameters
msgstring Debug message for warning print
Returns
void None
DebugPrint.LogWarning("Hello World, this is warning log");
static void LogWarning(string msg)
Prints debug message as warning message.
Definition DebugPrint.c:71

Definition at line 71 of file DebugPrint.c.

72 {
74 }
const int MSG_WARNING
Definition DebugPrint.c:4

References LogMessage(), MSG_WARNING, and s_TraceAllLogs.

◆ LogWarningAndTrace()

static void DebugPrint::LogWarningAndTrace ( string msg)
inlinestaticprivate

Prints debug message as warning message and prints stack trace of calls.

Parameters
msgstring Debug message for warning print
Returns
void None
DebugPrint.LogWarningAndTrace("Hello World, this is warning log");
>> -- Stack trace --
>> OnKeyPress() Scripts/mission/missionGameplay.c : 230
>> OnKeyPress() Scripts/DayZGame.c : 346
>> -----------------
static void LogWarningAndTrace(string msg)
Prints debug message as warning message and prints stack trace of calls.
Definition DebugPrint.c:90

Definition at line 90 of file DebugPrint.c.

91 {
93 }

References LogMessage(), and MSG_WARNING.

◆ OnInit()

static void DebugPrint::OnInit ( )
inlinestaticprivate

Definition at line 14 of file DebugPrint.c.

15 {
16 s_MsgPrefix[MSG_LOG] = "Log";
17 s_MsgPrefix[MSG_WARNING] = "Warning";
18 s_MsgPrefix[MSG_ERROR] = "Error";
19
20 s_MsgStackMarkStart = "-- Stack trace --";
21 s_MsgStackMarked = false;
22 s_MsgStackMarkEnd = "-----------------";
23
24 s_TraceAllLogs = false;
25 }

References MSG_ERROR, MSG_LOG, MSG_WARNING, s_MsgPrefix, s_MsgStackMarked, s_MsgStackMarkEnd, s_MsgStackMarkStart, and s_TraceAllLogs.

◆ TrimDebugLog()

string DebugPrint::TrimDebugLog ( string msg)
inlinestaticprivate

Definition at line 167 of file DebugPrint.c.

168 {
169 int msg_lenght = msg.Length();
170 int log_start = msg.IndexOf("'") + 1;
171
172 if (log_start == -1)
173 return msg;
174
175 int log_lenght = msg_lenght - log_start - 2;
176
177 return msg.Substring(log_start, log_lenght);
178 }

Referenced by AdjustDebugLog().

◆ TrimStackTrace()

string DebugPrint::TrimStackTrace ( string msg)
inlinestaticprivate

Definition at line 198 of file DebugPrint.c.

199 {
200 if (msg.IndexOf("DebugPrint.c") != -1)
201 return string.Empty;
202
203 return msg;
204 }

References string::Empty.

Referenced by AdjustDebugLog().

Member Data Documentation

◆ MSG_COUNT

const int DebugPrint::MSG_COUNT = 3
staticprivate

Definition at line 6 of file DebugPrint.c.

Referenced by IsDebugLog().

◆ MSG_ERROR

const int DebugPrint::MSG_ERROR = 2
staticprivate

Definition at line 5 of file DebugPrint.c.

Referenced by LogError(), LogErrorAndTrace(), and OnInit().

◆ MSG_LOG

const int DebugPrint::MSG_LOG = 0
staticprivate

Definition at line 3 of file DebugPrint.c.

Referenced by Log(), LogAndTrace(), and OnInit().

◆ MSG_WARNING

const int DebugPrint::MSG_WARNING = 1
staticprivate

Definition at line 4 of file DebugPrint.c.

Referenced by LogWarning(), LogWarningAndTrace(), and OnInit().

◆ s_MsgPrefix

string DebugPrint::s_MsgPrefix[MSG_COUNT]
staticprivate

Definition at line 8 of file DebugPrint.c.

Referenced by IsDebugLog(), LogMessage(), and OnInit().

◆ s_MsgStackMarked

bool DebugPrint::s_MsgStackMarked
staticprivate

Definition at line 11 of file DebugPrint.c.

Referenced by IsStackTrace(), and OnInit().

◆ s_MsgStackMarkEnd

string DebugPrint::s_MsgStackMarkEnd
staticprivate

Definition at line 10 of file DebugPrint.c.

Referenced by IsStackTrace(), and OnInit().

◆ s_MsgStackMarkStart

string DebugPrint::s_MsgStackMarkStart
staticprivate

Definition at line 9 of file DebugPrint.c.

Referenced by IsStackTrace(), and OnInit().

◆ s_TraceAllLogs

bool DebugPrint::s_TraceAllLogs
staticprivate

Definition at line 12 of file DebugPrint.c.

Referenced by EnableTracingLogs(), Log(), LogError(), LogWarning(), and OnInit().


The documentation for this class was generated from the following file: