OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
25 SOCKET _debug_socket = INVALID_SOCKET;
29 int _debug_driver_level;
32 int _debug_misc_level;
34 int _debug_sprite_level;
35 int _debug_oldloader_level;
37 int _debug_yapf_level;
38 int _debug_freetype_level;
39 int _debug_script_level;
41 int _debug_gamelog_level;
42 int _debug_desync_level;
43 int _debug_console_level;
45 int _debug_random_level;
53 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
61 DEBUG_LEVEL(oldloader),
64 DEBUG_LEVEL(freetype),
87 buf =
strecpy(buf,
"List of debug facility names:\n", last);
92 buf =
strecpy(buf, i->name, last);
93 length += strlen(i->name);
96 buf =
strecpy(buf,
"\n\n", last);
106 void DebugPrint(
const char *level,
const std::string &message)
108 if (_debug_socket != INVALID_SOCKET) {
109 std::string msg = fmt::format(
"{}dbg: [{}] {}\n",
GetLogPrefix(), level, message);
112 send(_debug_socket, msg.c_str(), (
int)msg.size(), 0);
115 if (strcmp(level,
"desync") == 0) {
117 if (f ==
nullptr)
return;
122 }
else if (strcmp(level,
"random") == 0) {
124 if (f ==
nullptr)
return;
126 fprintf(f,
"%s\n", message.c_str());
130 std::string msg = fmt::format(
"{}dbg: [{}] {}\n",
GetLogPrefix(), level, message);
131 fputs(msg.c_str(), stderr);
151 if (*s >=
'0' && *s <=
'9') {
154 v = strtoul(s, &end, 0);
157 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
166 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
167 if (*s ==
'\0')
break;
170 while (*s >=
'a' && *s <=
'z') s++;
174 for (i = debug_level; i !=
endof(debug_level); ++i) {
175 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
182 v = strtoul(s, &end, 0);
187 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
201 static char dbgstr[150];
204 memset(dbgstr, 0,
sizeof(dbgstr));
208 for (i++; i !=
endof(debug_level); i++) {
223 static char _log_prefix[24];
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
ClientSettings _settings_client
The current settings for this game.
void NetworkAdminConsole(const std::string_view origin, const std::string_view string)
Send console to the admin network (if they did opt in for the respective update).
bool show_date_in_logs
whether to show dates in console logs
char * DumpDebugFacilityNames(char *buf, char *last)
Dump the available debug facility names in the help text.
const char * GetLogPrefix()
Get the prefix for logs; if show_date_in_logs is enabled it returns the date, otherwise it returns no...
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
static const TextColour CC_DEBUG
Colour for debug output.
uint8 developer
print non-fatal warnings in console (>= 1), copy debug output to console (== 2)
static size_t Format(char *buffer, const char *last, const char *format) NOACCESS(2) WARN_TIME_FORMAT(3)
Format the current time with the given strftime format specifiers.
#define endof(x)
Get the end element of an fixed size array.
const char * GetDebugString()
Print out the current debug-level.
void DebugPrint(const char *level, const std::string &message)
Internal function for outputting the debug line.
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
char * strecat(char *dst, const char *src, const char *last)
Appends characters from one string to another.
#define lastof(x)
Get the last element of an fixed size array.
GUISettings gui
settings related to the GUI
void IConsolePrint(TextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.