Go to the documentation of this file.
26 SOCKET _debug_socket = INVALID_SOCKET;
40 int _debug_driver_level;
43 int _debug_misc_level;
45 int _debug_sprite_level;
46 int _debug_oldloader_level;
48 int _debug_yapf_level;
49 int _debug_freetype_level;
50 int _debug_script_level;
52 int _debug_gamelog_level;
53 int _debug_desync_level;
54 int _debug_console_level;
56 int _debug_random_level;
64 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
72 DEBUG_LEVEL(oldloader),
75 DEBUG_LEVEL(freetype),
98 buf =
strecpy(buf,
"List of debug facility names:\n", last);
100 buf =
strecpy(buf,
", ", last);
103 buf =
strecpy(buf, i->name, last);
104 length += strlen(i->name);
107 buf =
strecpy(buf,
"\n\n", last);
117 void DebugPrint(
const char *level,
const std::string &message)
119 if (_debug_socket != INVALID_SOCKET) {
120 std::string msg = fmt::format(
"{}dbg: [{}] {}\n",
GetLogPrefix(), level, message);
123 static std::mutex _debug_socket_mutex;
124 std::lock_guard<std::mutex>
lock(_debug_socket_mutex);
128 send(_debug_socket, msg.c_str(), (
int)msg.size(), 0);
131 if (strcmp(level,
"desync") == 0) {
133 if (f ==
nullptr)
return;
138 }
else if (strcmp(level,
"random") == 0) {
140 if (f ==
nullptr)
return;
142 fprintf(f,
"%s\n", message.c_str());
146 std::string msg = fmt::format(
"{}dbg: [{}] {}\n",
GetLogPrefix(), level, message);
147 fputs(msg.c_str(), stderr);
170 if (*s >=
'0' && *s <=
'9') {
173 v = strtoul(s, &end, 0);
176 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
185 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
186 if (*s ==
'\0')
break;
189 while (*s >=
'a' && *s <=
'z') s++;
193 for (i = debug_level; i !=
endof(debug_level); ++i) {
194 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
201 v = strtoul(s, &end, 0);
206 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
220 static char dbgstr[150];
223 memset(dbgstr, 0,
sizeof(dbgstr));
227 for (i++; i !=
endof(debug_level); i++) {
242 static char _log_prefix[24];
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
std::atomic< bool > _debug_remote_console
Whether we need to send data to either NetworkAdminConsole or IConsolePrint.
std::mutex lock
synchronization for playback status fields
@ ADMIN_UPDATE_CONSOLE
The admin would like to have console messages.
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
@ 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).
std::string level
The used debug level.
bool show_date_in_logs
whether to show dates in console logs
std::string message
The actual formatted message.
std::vector< QueuedDebugItem > _debug_remote_console_queue_spare
Spare queue to swap with _debug_remote_console_queue.
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.
std::vector< QueuedDebugItem > _debug_remote_console_queue
Queue for debug messages to be passed to NetworkAdminConsole or IConsolePrint.
#define endof(x)
Get the end element of an fixed size array.
const char * GetDebugString()
Print out the current debug-level.
Class for handling the server side of the game connection.
void DebugPrint(const char *level, const std::string &message)
Internal function for outputting the debug line.
@ ADMIN_FREQUENCY_AUTOMATIC
The admin gets information about this when it changes.
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
void DebugSendRemoteMessages()
Send the queued Debug messages to either NetworkAdminConsole or IConsolePrint from the GameLoop threa...
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
std::mutex _debug_remote_console_mutex
Mutex to guard the queue of debug messages for either NetworkAdminConsole or IConsolePrint.
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.
Element in the queue of debug messages that have to be passed to either NetworkAdminConsole or IConso...
#define lastof(x)
Get the last element of an fixed size array.
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
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.