Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
debugprint.c
Go to the documentation of this file.
1
class
DebugPrint
2
{
3
static
private
const
int
MSG_LOG
= 0;
4
static
private
const
int
MSG_WARNING
= 1;
5
static
private
const
int
MSG_ERROR
= 2;
6
static
private
const
int
MSG_COUNT
= 3;
7
8
static
private
string
s_MsgPrefix
[
MSG_COUNT
];
9
static
private
string
s_MsgStackMarkStart
;
10
static
private
string
s_MsgStackMarkEnd
;
11
static
private
bool
s_MsgStackMarked
;
12
static
private
bool
s_TraceAllLogs
;
13
14
static
void
OnInit
()
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
}
26
37
static
void
Log
(
string
msg)
38
{
39
LogMessage
(msg,
MSG_LOG
,
s_TraceAllLogs
);
40
}
41
56
static
void
LogAndTrace
(
string
msg)
57
{
58
LogMessage
(msg,
MSG_LOG
,
true
);
59
}
60
71
static
void
LogWarning
(
string
msg)
72
{
73
LogMessage
(msg,
MSG_WARNING
,
s_TraceAllLogs
);
74
}
75
90
static
void
LogWarningAndTrace
(
string
msg)
91
{
92
LogMessage
(msg,
MSG_WARNING
,
true
);
93
}
94
105
static
void
LogError
(
string
msg)
106
{
107
LogMessage
(msg,
MSG_ERROR
,
s_TraceAllLogs
);
108
}
109
124
static
void
LogErrorAndTrace
(
string
msg)
125
{
126
LogMessage
(msg,
MSG_ERROR
,
true
);
127
}
128
141
static
string
AdjustDebugLog
(
string
msg)
142
{
143
if
(
IsStackTrace
(msg) )
144
{
145
return
TrimStackTrace
(msg);
146
}
147
148
if
(
IsDebugLog
(msg) )
149
{
150
return
TrimDebugLog
(msg);
151
}
152
153
return
msg;
154
}
155
156
static
void
EnableTracingLogs
(
bool
enable)
157
{
158
s_TraceAllLogs
= enable;
159
}
160
161
static
private
bool
IsDebugLog
(
string
msg)
162
{
163
for
(
int
i = 0; i <
MSG_COUNT
; ++i )
164
{
165
if
( msg.
IndexOf
(
s_MsgPrefix
[i]) != -1 )
166
{
167
return
true
;
168
}
169
}
170
171
return
false
;
172
}
173
static
private
string
TrimDebugLog
(
string
msg)
174
{
175
int
msg_lenght = msg.
Length
();
176
int
log_start = msg.
IndexOf
(
"'"
) + 1;
177
178
if
( log_start == -1 )
179
{
180
return
msg;
181
}
182
183
int
log_lenght = msg_lenght - log_start - 2;
184
185
return
msg.
Substring
(log_start, log_lenght);
186
}
187
static
private
bool
IsStackTrace
(
string
msg)
188
{
189
if
(
s_MsgStackMarked
&& msg.
IndexOf
(
s_MsgStackMarkEnd
) != -1 )
190
{
191
s_MsgStackMarked
=
false
;
192
return
false
;
193
}
194
195
if
(
s_MsgStackMarked
)
196
{
197
return
true
;
198
}
199
200
if
( msg.
IndexOf
(
s_MsgStackMarkStart
) != -1 )
201
{
202
s_MsgStackMarked
=
true
;
203
return
true
;
204
}
205
206
return
false
;
207
}
208
static
private
string
TrimStackTrace
(
string
msg)
209
{
210
if
( msg.
IndexOf
(
"DebugPrint.c"
) != -1 )
211
{
212
return
string
.Empty;
213
}
214
215
return
msg;
216
}
217
218
static
private
void
LogMessage
(
string
msg,
int
msg_type,
bool
trace=
false
)
219
{
220
string
mesg =
"["
+
s_MsgPrefix
[msg_type]+
"]: "
+msg;
221
222
Print
(mesg);
223
224
if
( trace )
225
{
226
DumpStack
();
227
}
228
}
229
};
DebugPrint
Definition
debugprint.c:2
DebugPrint::EnableTracingLogs
static void EnableTracingLogs(bool enable)
Definition
debugprint.c:156
DebugPrint::s_MsgStackMarked
bool s_MsgStackMarked
Definition
debugprint.c:11
DebugPrint::IsStackTrace
bool IsStackTrace(string msg)
Definition
debugprint.c:187
DebugPrint::LogMessage
void LogMessage(string msg, int msg_type, bool trace=false)
Definition
debugprint.c:218
DebugPrint::LogWarningAndTrace
static void LogWarningAndTrace(string msg)
Prints debug message as warning message and prints stack trace of calls.
Definition
debugprint.c:90
DebugPrint::s_MsgPrefix
string s_MsgPrefix[MSG_COUNT]
Definition
debugprint.c:8
DebugPrint::s_MsgStackMarkEnd
string s_MsgStackMarkEnd
Definition
debugprint.c:10
DebugPrint::LogWarning
static void LogWarning(string msg)
Prints debug message as warning message.
Definition
debugprint.c:71
DebugPrint::MSG_WARNING
const int MSG_WARNING
Definition
debugprint.c:4
DebugPrint::MSG_LOG
const int MSG_LOG
Definition
debugprint.c:3
DebugPrint::LogError
static void LogError(string msg)
Prints debug message as error message.
Definition
debugprint.c:105
DebugPrint::MSG_ERROR
const int MSG_ERROR
Definition
debugprint.c:5
DebugPrint::AdjustDebugLog
static string AdjustDebugLog(string msg)
Function adjust received message for debug console (Do not use).
Definition
debugprint.c:141
DebugPrint::s_MsgStackMarkStart
string s_MsgStackMarkStart
Definition
debugprint.c:9
DebugPrint::Log
static void Log(string msg)
Prints debug message with normal prio.
Definition
debugprint.c:37
DebugPrint::IsDebugLog
bool IsDebugLog(string msg)
Definition
debugprint.c:161
DebugPrint::OnInit
static void OnInit()
Definition
debugprint.c:14
DebugPrint::TrimDebugLog
string TrimDebugLog(string msg)
Definition
debugprint.c:173
DebugPrint::s_TraceAllLogs
bool s_TraceAllLogs
Definition
debugprint.c:12
DebugPrint::LogAndTrace
static void LogAndTrace(string msg)
Prints debug message as normal message and prints stack trace of calls.
Definition
debugprint.c:56
DebugPrint::LogErrorAndTrace
static void LogErrorAndTrace(string msg)
Prints debug message as error message and prints stack trace of calls.
Definition
debugprint.c:124
DebugPrint::TrimStackTrace
string TrimStackTrace(string msg)
Definition
debugprint.c:208
DebugPrint::MSG_COUNT
const int MSG_COUNT
Definition
debugprint.c:6
DumpStack
proto void DumpStack()
Prints current call stack (stack trace).
Print
proto void Print(void var)
Prints content of variable to console/log.
string::Substring
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
string::IndexOf
proto native int IndexOf(string sample)
Finds 'sample' in 'str'.
string::Length
proto native int Length()
Returns length of string.
Games
Dayz
scripts
3_game
tools
debugprint.c
Generated by
1.17.0