23#include "3rdparty/fmt/chrono.h"
70 fmt::format_to(output_iterator,
"List of debug facility names:\n");
72 fmt::format_to(output_iterator,
", ");
78 fmt::format_to(output_iterator,
"\n\n");
92 if (!f.has_value())
return;
99 if (!f.has_value())
return;
101 fmt::print(*f,
"{}\n", message);
131 if (level.has_value()) {
132 new_debug_level.fill(
static_cast<Severity>(*level));
135 static const std::string_view lowercase_letters{
"abcdefghijklmnopqrstuvwxyz"};
136 static const std::string_view lowercase_letters_and_digits{
"abcdefghijklmnopqrstuvwxyz0123456789"};
147 error_func(fmt::format(
"Unknown debug level '{}'", key));
155 if (!level.has_value()) {
156 error_func(fmt::format(
"Level for '{}' must be a valid integer.", key));
176 if (!result.empty()) result +=
", ";
193 std::string log_prefix;
195 log_prefix = fmt::format(
"[{:%Y-%m-%d %H:%M:%S}] ", fmt::localtime(time(
nullptr)));
Iterate a range of enum values.
Class for handling the server side of the game connection.
static Pool::IterateWrapperFiltered< ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter > IterateActive(size_t from=0)
Returns an iterable ensemble of all active admin sockets.
Parse data from a string / buffer.
std::optional< T > TryReadIntegerBase(int base, bool clamp=false)
Try to read and parse an integer in number 'base', and then advance the reader.
bool AnyBytesLeft() const noexcept
Check whether any bytes left to read.
std::string_view ReadUntilCharNotIn(std::string_view chars)
Read 8-bit chars, while they are in 'chars', until they are not; and advance reader.
void SkipUntilCharIn(std::string_view chars)
Skip 8-bit chars, while they are not in 'chars', until they are.
void IConsolePrint(ExtendedTextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.
Console functions used outside of the console code.
static const TextColour CC_DEBUG
Colour for debug output.
std::string GetLogPrefix(bool force)
Get the prefix for logs.
std::vector< QueuedDebugItem > _debug_remote_console_queue
Queue for debug messages to be passed to NetworkAdminConsole or IConsolePrint.
std::mutex _debug_remote_console_mutex
Mutex to guard the queue of debug messages for either NetworkAdminConsole or IConsolePrint.
void SetDebugString(std::string_view s, SetDebugStringErrorFunc error_func)
Set debugging levels by parsing the text in s.
void DebugReconsiderSendRemoteMessages()
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
std::atomic< bool > _debug_remote_console
Whether we need to send data to either NetworkAdminConsole or IConsolePrint.
void DumpDebugFacilityNames(std::back_insert_iterator< std::string > &output_iterator)
Dump the available debug facility names in the help text.
std::vector< QueuedDebugItem > _debug_remote_console_queue_spare
Spare queue to swap with _debug_remote_console_queue.
EnumIndexArray< Severity, Facility, Facility::End > _debug_level
Severity level for each debug facility.
std::string GetDebugString()
Print out the current debug-level.
void DebugSendRemoteMessages()
Send the queued Debug messages to either NetworkAdminConsole or IConsolePrint from the GameLoop threa...
void DebugPrint(Facility facility, Severity severity, std::string &&message)
Internal function for outputting the debug line.
static EnumIndexArray< std::string_view, Facility, Facility::End > _debug_facilities
Name for each debug facility.
Functions related to debugging.
Facility
Debug facilities.
@ Desync
Desync message facility.
@ Random
Random message facility.
Severity
Debug message severity levels.
@ Critical
Critical, user should know about this.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
std::optional< FileHandle > FioFOpenFile(std::string_view filename, std::string_view mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
Functions for standard in/out file operations.
@ Autosave
Subdirectory of save for autosaves.
void NetworkAdminConsole(std::string_view origin, std::string_view string)
Send console to the admin network (if they did opt in for the respective update).
Server part of the admin network protocol.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
Types related to global configuration settings.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
Element in the queue of debug messages that have to be passed to either NetworkAdminConsole or IConso...
Facility facility
The facility of the message.
std::string message
The actual formatted message.
@ Console
The admin would like to have console messages.
@ Automatic
The admin gets information about this when it changes.
Declarations of functions for MS windows systems.
std::mutex lock
synchronization for playback status fields