more updates considering the new 'debug' log level
This commit is contained in:
parent
79e8c7d7b5
commit
c2a6fdad58
5 changed files with 48 additions and 41 deletions
|
@ -68,18 +68,13 @@ at, in a corner of the screen.
|
|||
.BR -h ", " --help
|
||||
displays a summary of command line options to standard output, and exits.
|
||||
.TP
|
||||
.BI --load \ savegame
|
||||
.BI --load \ <savegame>
|
||||
loads the file savegame from the standard save game directory.
|
||||
.TP
|
||||
.BR --log-error="domain1,domain2,..." ", " --log-warning="..." ", " --log-info="..."
|
||||
.BR --log-<level>="domain1,domain2,..."
|
||||
sets the severity level of the debug domains. "all" can be used to match
|
||||
any debug domain.
|
||||
.B --log-info
|
||||
shows all messages,
|
||||
.B --log-warning
|
||||
only warnings and errors, and
|
||||
.B --log-error
|
||||
just errors.
|
||||
any debug domain. Available levels: error, warning, info, debug. By default the
|
||||
error level is used.
|
||||
.TP
|
||||
.B --logdomains
|
||||
Dumps a list of all log domains and exits.
|
||||
|
@ -118,6 +113,11 @@ runs the game in windowed mode.
|
|||
.BR --no-delay
|
||||
runs the game without any delays for graphic benchmarking. This is automatically enabled by --nogui.
|
||||
.TP
|
||||
.B --nogui
|
||||
runs the game without the GUI. Must appear before
|
||||
.B --multiplayer
|
||||
to have the desired effect.
|
||||
.TP
|
||||
.BR --exit-at-end
|
||||
exits once the scenario is over, without displaying victory/defeat dialog which requires the user to click OK. This is also used for scriptable benchmarking.
|
||||
.
|
||||
|
@ -139,11 +139,6 @@ use this option to play in the selected era instead of the "Default"
|
|||
era. The era is chosen by an id. Eras are described in the
|
||||
data/multiplayer.cfg file.
|
||||
.TP
|
||||
.B --nogui
|
||||
runs the game without the GUI. Must appear before
|
||||
.B --multiplayer
|
||||
to have the desired effect.
|
||||
.TP
|
||||
.B --parm<number>=name:value
|
||||
sets additional parameters for this side. This parameter depends on the
|
||||
options used with
|
||||
|
|
|
@ -45,7 +45,7 @@ on what commands the server accepts via the wesnoth client or the socket.
|
|||
.BI -c,\ --config \ path
|
||||
tells wesnothd where to find the config file to use. See the section
|
||||
.B SERVER CONFIG
|
||||
below for the syntax.
|
||||
below for the syntax. You can reload the config with sending SIGHUP to the server process.
|
||||
.TP
|
||||
.B -d,\ --daemon
|
||||
runs wesnothd as a daemon.
|
||||
|
@ -53,6 +53,10 @@ runs wesnothd as a daemon.
|
|||
.B -h,\ --help
|
||||
tells you what the command line options do.
|
||||
.TP
|
||||
.BR --log-<level>="domain1,domain2,..."
|
||||
sets the severity level of the debug domains. "all" can be used to match
|
||||
any debug domain. Available levels: error, warning, info, debug.
|
||||
.TP
|
||||
.BI -p,\ --port \ port
|
||||
binds the server to the specified port. If no port is specified, port
|
||||
15000 will be used.
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
#define DBG_NW LOG_STREAM(debug, network)
|
||||
#define LOG_NW LOG_STREAM(info, network)
|
||||
#define WRN_NW LOG_STREAM(warn, network)
|
||||
#define ERR_NW LOG_STREAM(err, network)
|
||||
|
@ -233,7 +234,7 @@ server_manager::server_manager(int port, CREATE_SERVER create_server) : free_(fa
|
|||
}
|
||||
}
|
||||
|
||||
LOG_NW << "server socket initialized: " << server_socket << "\n";
|
||||
DBG_NW << "server socket initialized: " << server_socket << "\n";
|
||||
free_ = true;
|
||||
}
|
||||
}
|
||||
|
@ -361,10 +362,10 @@ void connect_operation::run()
|
|||
|
||||
// No blocking operations from here on
|
||||
const threading::lock l(get_mutex());
|
||||
LOG_NW << "sent handshake...\n";
|
||||
DBG_NW << "sent handshake...\n";
|
||||
|
||||
if(is_aborted()) {
|
||||
LOG_NW << "connect operation aborted by calling thread\n";
|
||||
DBG_NW << "connect operation aborted by calling thread\n";
|
||||
SDLNet_TCP_Close(sock);
|
||||
return;
|
||||
}
|
||||
|
@ -425,7 +426,7 @@ connection accept_connection()
|
|||
|
||||
const TCPsocket sock = SDLNet_TCP_Accept(server_socket);
|
||||
if(sock) {
|
||||
LOG_NW << "received connection. Pending handshake...\n";
|
||||
DBG_NW << "received connection. Pending handshake...\n";
|
||||
pending_sockets.push_back(sock);
|
||||
if(pending_socket_set == 0) {
|
||||
pending_socket_set = SDLNet_AllocSocketSet(512);
|
||||
|
@ -445,7 +446,7 @@ connection accept_connection()
|
|||
return 0;
|
||||
}
|
||||
|
||||
LOG_NW << "pending socket activity...\n";
|
||||
DBG_NW << "pending socket activity...\n";
|
||||
|
||||
for(std::vector<TCPsocket>::iterator i = pending_sockets.begin(); i != pending_sockets.end(); ++i) {
|
||||
if(!SDLNet_SocketReady(*i)) {
|
||||
|
@ -460,7 +461,7 @@ connection accept_connection()
|
|||
SDLNet_TCP_DelSocket(pending_socket_set,sock);
|
||||
pending_sockets.erase(i);
|
||||
|
||||
LOG_NW << "receiving data from pending socket...\n";
|
||||
DBG_NW << "receiving data from pending socket...\n";
|
||||
|
||||
const int len = SDLNet_TCP_Recv(sock,buf,4);
|
||||
if(len != 4) {
|
||||
|
@ -471,7 +472,7 @@ connection accept_connection()
|
|||
|
||||
const int handle = SDLNet_Read32(buf);
|
||||
|
||||
LOG_NW << "received handshake from client: '" << handle << "'\n";
|
||||
DBG_NW << "received handshake from client: '" << handle << "'\n";
|
||||
|
||||
const int res = SDLNet_TCP_AddSocket(socket_set,sock);
|
||||
if(res == -1) {
|
||||
|
@ -540,7 +541,7 @@ bool disconnect(connection s)
|
|||
remove_connection(s);
|
||||
} else {
|
||||
if(sockets.size() == 1) {
|
||||
LOG_NW << "valid socket: " << static_cast<int>(*sockets.begin()) << "\n";
|
||||
DBG_NW << "valid socket: " << static_cast<int>(*sockets.begin()) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -649,21 +650,23 @@ connection receive_data(config& cfg, connection connection_num)
|
|||
|
||||
void send_data(const config& cfg, connection connection_num)
|
||||
{
|
||||
LOG_NW << "in send_data()...\n";
|
||||
DBG_NW << "in send_data()...\n";
|
||||
|
||||
if(cfg.empty()) {
|
||||
return;
|
||||
}
|
||||
LOG_NW << "SENDING to: " << connection_num << ": " << cfg.debug();
|
||||
|
||||
if(bad_sockets.count(connection_num) || bad_sockets.count(0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
log_scope2(network, "sending data");
|
||||
// log_scope2(network, "sending data");
|
||||
if(!connection_num) {
|
||||
LOG_NW << "sockets: " << sockets.size() << "\n";
|
||||
DBG_NW << "sockets: " << sockets.size() << "\n";
|
||||
for(sockets_list::const_iterator i = sockets.begin();
|
||||
i != sockets.end(); ++i) {
|
||||
LOG_NW << "server socket: " << server_socket << "\ncurrent socket: " << *i << "\n";
|
||||
DBG_NW << "server socket: " << server_socket << "\ncurrent socket: " << *i << "\n";
|
||||
send_data(cfg,*i);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -69,9 +69,10 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define DBG_NW LOG_STREAM(debug, network)
|
||||
#define LOG_NW LOG_STREAM(info, network)
|
||||
#define ERR_NW LOG_STREAM(err, network)
|
||||
|
||||
namespace {
|
||||
struct _TCPsocket {
|
||||
int ready;
|
||||
|
@ -303,7 +304,7 @@ static SOCKET_STATE receive_buf(TCPsocket sock, std::vector<char>& buf)
|
|||
|
||||
static int process_queue(void*)
|
||||
{
|
||||
LOG_NW << "thread started...\n";
|
||||
DBG_NW << "thread started...\n";
|
||||
for(;;) {
|
||||
|
||||
//if we find a socket to send data to, sent_buf will be non-NULL. If we find a socket
|
||||
|
@ -323,7 +324,7 @@ static int process_queue(void*)
|
|||
|
||||
}
|
||||
if(min_threads && waiting_threads >= min_threads) {
|
||||
LOG_NW << "worker thread exiting... not enough job\n";
|
||||
DBG_NW << "worker thread exiting... not enough job\n";
|
||||
to_clear.push_back(threading::get_current_thread_id());
|
||||
return 0;
|
||||
}
|
||||
|
@ -363,7 +364,7 @@ static int process_queue(void*)
|
|||
}
|
||||
|
||||
if(managed == false) {
|
||||
LOG_NW << "worker thread exiting...\n";
|
||||
DBG_NW << "worker thread exiting...\n";
|
||||
waiting_threads--;
|
||||
to_clear.push_back(threading::get_current_thread_id());
|
||||
return 0;
|
||||
|
@ -384,7 +385,7 @@ static int process_queue(void*)
|
|||
|
||||
wassert(sock);
|
||||
|
||||
LOG_NW << "thread found a buffer...\n";
|
||||
DBG_NW << "thread found a buffer...\n";
|
||||
|
||||
SOCKET_STATE result = SOCKET_READY;
|
||||
std::vector<char> buf;
|
||||
|
@ -457,9 +458,9 @@ manager::~manager()
|
|||
cond->notify_all();
|
||||
|
||||
for(std::map<Uint32,threading::thread*>::const_iterator i = threads.begin(); i != threads.end(); ++i) {
|
||||
LOG_NW << "waiting for thread " << i->first << " to exit...\n";
|
||||
DBG_NW << "waiting for thread " << i->first << " to exit...\n";
|
||||
delete i->second;
|
||||
LOG_NW << "thread exited...\n";
|
||||
DBG_NW << "thread exited...\n";
|
||||
}
|
||||
|
||||
threads.clear();
|
||||
|
@ -472,7 +473,7 @@ manager::~manager()
|
|||
sockets_locked.clear();
|
||||
transfer_stats.clear();
|
||||
|
||||
LOG_NW << "exiting manager::~manager()\n";
|
||||
DBG_NW << "exiting manager::~manager()\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,7 +525,7 @@ TCPsocket get_received_data(TCPsocket sock, config& cfg)
|
|||
|
||||
void queue_data(TCPsocket sock,const config& buf)
|
||||
{
|
||||
LOG_NW << "queuing data...\n";
|
||||
DBG_NW << "queuing data...\n";
|
||||
|
||||
{
|
||||
const threading::lock lock(*global_mutex);
|
||||
|
|
|
@ -1451,11 +1451,15 @@ int main(int argc, char** argv) {
|
|||
} else if (val == "--help" || val == "-h") {
|
||||
std::cout << "usage: " << argv[0]
|
||||
<< " [-dvV] [-c path] [-m n] [-p port] [-t n]\n"
|
||||
<< " -c --config path Tells wesnothd where to find the config file to use.\n"
|
||||
<< " -d --daemon Runs wesnothd as a daemon.\n"
|
||||
<< " -h --help Shows this usage message.\n"
|
||||
<< " -p, --port port Binds the server to the specified port.\n"
|
||||
<< " -t, --threads n Uses n worker threads for network I/O (default: 5).\n"
|
||||
<< " -c, --config <path> Tells wesnothd where to find the config file to use.\n"
|
||||
<< " -d, --daemon Runs wesnothd as a daemon.\n"
|
||||
<< " -h, --help Shows this usage message.\n"
|
||||
<< " --log-<level>="<domain1>,<domain2>,..."
|
||||
<< " sets the severity level of the debug domains.
|
||||
<< " \"all\" can be used to match any debug domain.
|
||||
<< " Available levels: error, warning, info, debug.
|
||||
<< " -p, --port <port> Binds the server to the specified port.\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";
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue