Add -w option to wesnothd to print all WML it sends to stdout

This commit is contained in:
loonycyborg 2021-01-05 20:07:22 +03:00
parent 922f2b6ad5
commit 27ea013763
3 changed files with 12 additions and 1 deletions

View file

@ -51,6 +51,8 @@ static lg::log_domain log_config("config");
#define ERR_CONFIG LOG_STREAM(err, log_config)
#define WRN_CONFIG LOG_STREAM(warn, log_config)
bool dump_wml = false;
server_base::server_base(unsigned short port, bool keep_alive)
: port_(port)
, keep_alive_(keep_alive)
@ -235,6 +237,10 @@ void info_table_into_simple_wml(simple_wml::document& doc, const std::string& pa
*/
void server_base::coro_send_doc(socket_ptr socket, simple_wml::document& doc, boost::asio::yield_context yield)
{
if(dump_wml) {
std::cout << "Sending WML to " << client_address(socket) << ": \n" << doc.output() << std::endl;
}
try {
simple_wml::string_span s = doc.output_compressed();

View file

@ -38,6 +38,8 @@
#include <map>
extern bool dump_wml;
typedef std::shared_ptr<boost::asio::ip::tcp::socket> socket_ptr;
struct server_shutdown : public game::error

View file

@ -2945,6 +2945,8 @@ int main(int argc, char** argv)
config_file = argv[++arg];
} else if(val == "--verbose" || val == "-v") {
lg::set_log_domain_severity("all", lg::debug());
} else if(val == "--dump-wml" || val == "-w") {
dump_wml = true;
} else if(val.substr(0, 6) == "--log-") {
std::size_t p = val.find('=');
if(p == std::string::npos) {
@ -2997,7 +2999,8 @@ int main(int argc, char** argv)
<< " --keepalive Enable TCP keepalive.\n"
<< " -t, --threads <n> Uses n worker threads for network I/O (default: 5).\n"
<< " -v --verbose Turns on more verbose logging.\n"
<< " -V, --version Returns the server version.\n";
<< " -V, --version Returns the server version.\n"
<< " -w, --dump-wml Print all WML sent to clients to stdout.\n";
return 0;
} else if(val == "--version" || val == "-V") {
std::cout << "Battle for Wesnoth server " << game_config::wesnoth_version.str() << "\n";