Merge branch 'feature/campaignd-log-rework'
This commit is contained in:
commit
cc1049bc51
1 changed files with 14 additions and 10 deletions
|
@ -48,8 +48,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static lg::log_domain log_network("network");
|
static lg::log_domain log_campaignd("campaignd");
|
||||||
#define LOG_CS if(lg::err.dont_log(log_network)) ; else lg::err(log_network, false)
|
#define DBG_CS LOG_STREAM(debug, log_campaignd)
|
||||||
|
#define LOG_CS LOG_STREAM(info, log_campaignd)
|
||||||
|
#define WRN_CS LOG_STREAM(warn, log_campaignd)
|
||||||
|
#define ERR_CS LOG_STREAM(err, log_campaignd)
|
||||||
|
|
||||||
//compatibility code for MS compilers
|
//compatibility code for MS compilers
|
||||||
#ifndef SIGHUP
|
#ifndef SIGHUP
|
||||||
|
@ -177,7 +180,7 @@ void server::load_blacklist()
|
||||||
blacklist_.read(blcfg);
|
blacklist_.read(blcfg);
|
||||||
LOG_CS << "using blacklist from " << blacklist_file_ << '\n';
|
LOG_CS << "using blacklist from " << blacklist_file_ << '\n';
|
||||||
} catch(const config::error&) {
|
} catch(const config::error&) {
|
||||||
LOG_CS << "ERROR: failed to read blacklist from " << blacklist_file_ << ", blacklist disabled\n";
|
ERR_CS << "failed to read blacklist from " << blacklist_file_ << ", blacklist disabled\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,13 +203,13 @@ void server::fire(const std::string& hook, const std::string& addon)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
LOG_CS << "ERROR: Tried to execute a script on an unsupported platform" << std::endl;
|
ERR_CS << "Tried to execute a script on an unsupported platform\n";
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
pid_t childpid;
|
pid_t childpid;
|
||||||
|
|
||||||
if((childpid = fork()) == -1) {
|
if((childpid = fork()) == -1) {
|
||||||
LOG_CS << "ERROR: fork failed while updating campaign " << addon << std::endl;
|
ERR_CS << "fork failed while updating campaign " << addon << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +241,7 @@ void server::send_error(const std::string& msg, network::connection sock)
|
||||||
{
|
{
|
||||||
config cfg;
|
config cfg;
|
||||||
cfg.add_child("error")["message"] = msg;
|
cfg.add_child("error")["message"] = msg;
|
||||||
LOG_CS << "ERROR [" << network::ip_address(sock) << "]: " << msg << '\n';
|
ERR_CS << "[" << network::ip_address(sock) << "]: " << msg << '\n';
|
||||||
network::send_data(cfg, sock);
|
network::send_data(cfg, sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +301,7 @@ void server::run()
|
||||||
}
|
}
|
||||||
} catch(network::error& e) {
|
} catch(network::error& e) {
|
||||||
if(!e.socket) {
|
if(!e.socket) {
|
||||||
LOG_CS << "fatal network error: " << e.message << "\n";
|
ERR_CS << "fatal network error: " << e.message << "\n";
|
||||||
throw;
|
throw;
|
||||||
} else {
|
} else {
|
||||||
LOG_CS << "client disconnect: " << e.message << " " << network::ip_address(e.socket) << "\n";
|
LOG_CS << "client disconnect: " << e.message << " " << network::ip_address(e.socket) << "\n";
|
||||||
|
@ -317,7 +320,7 @@ void server::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err_sock) {
|
if(err_sock) {
|
||||||
LOG_CS << "client disconnect due to exception: " << e.what() << " " << network::ip_address(err_sock) << "\n";
|
ERR_CS << "client disconnect due to exception: " << e.what() << " " << network::ip_address(err_sock) << "\n";
|
||||||
network::disconnect(err_sock);
|
network::disconnect(err_sock);
|
||||||
} else {
|
} else {
|
||||||
throw;
|
throw;
|
||||||
|
@ -445,7 +448,7 @@ void server::handle_request_campaign(const server::request& req)
|
||||||
|
|
||||||
if(size < 0) {
|
if(size < 0) {
|
||||||
std::cerr << " size: <unknown> KiB\n";
|
std::cerr << " size: <unknown> KiB\n";
|
||||||
LOG_CS << "File size unknown, aborting send.\n";
|
ERR_CS << "File size unknown, aborting send.\n";
|
||||||
send_error("Add-on '" + req.cfg["name"].str() + "' could not be read by the server.", req.sock);
|
send_error("Add-on '" + req.cfg["name"].str() + "' could not be read by the server.", req.sock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -655,7 +658,7 @@ void server::handle_delete(const server::request& req)
|
||||||
// Erase the campaign.
|
// Erase the campaign.
|
||||||
write_file(campaign["filename"], std::string());
|
write_file(campaign["filename"], std::string());
|
||||||
if(remove(campaign["filename"].str().c_str()) != 0) {
|
if(remove(campaign["filename"].str().c_str()) != 0) {
|
||||||
LOG_CS << "failed to delete archive for campaign '" << erase["name"]
|
ERR_CS << "failed to delete archive for campaign '" << erase["name"]
|
||||||
<< "' (" << campaign["filename"] << "): " << strerror(errno)
|
<< "' (" << campaign["filename"] << "): " << strerror(errno)
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
@ -710,6 +713,7 @@ int main(int argc, char**argv)
|
||||||
{
|
{
|
||||||
game_config::path = get_cwd();
|
game_config::path = get_cwd();
|
||||||
|
|
||||||
|
lg::set_log_domain_severity("campaignd", lg::info);
|
||||||
lg::timestamps(true);
|
lg::timestamps(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue