put stat upload logs in a separate logdomain, patch by corn
This commit is contained in:
parent
c2f09875dd
commit
b66dffb955
4 changed files with 19 additions and 5 deletions
|
@ -4,6 +4,7 @@ Version 1.7.0-svn:
|
|||
and it is now <preferences>/data/add-ons
|
||||
* Added --rng-seed command line option to specify a value to seed the random
|
||||
number generator with.
|
||||
* new logdomain : uploader to see stat-upload related actions
|
||||
* AI:
|
||||
* Fixed incorrect handling of poisoning attacks when suggesting best attack
|
||||
in user interface
|
||||
|
|
|
@ -54,7 +54,7 @@ log_domain general("general"), ai("ai"), ai_actions("ai_actions"), ai_configurat
|
|||
filesystem("filesystem"), audio("audio"),
|
||||
replay("replay"), help("help"), gui("gui"), gui_parse("gui_parse"),
|
||||
gui_draw("gui_draw"), gui_layout("gui_layout"), gui_event("gui_event"), editor("editor"), wml("wml"),
|
||||
mp_user_handler("user_handler"), lua("lua");
|
||||
mp_user_handler("user_handler"), uploader("uploader"), lua("lua");
|
||||
|
||||
log_domain::log_domain(char const *name) : domain_(log_domains.size())
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ std::string get_timestamp(const time_t& t, const std::string& format="%Y%m%d %H:
|
|||
extern logger err, warn, info, debug;
|
||||
extern log_domain general, ai, ai_actions, ai_configuration, ai_manager, formula_ai, cache, config,
|
||||
display, engine, network, mp_server, filesystem, audio, replay, help, gui, gui_parse,
|
||||
gui_layout, gui_draw, gui_event, editor, wml, mp_user_handler, lua;
|
||||
gui_layout, gui_draw, gui_event, editor, wml, mp_user_handler, lua, uploader;
|
||||
|
||||
class scope_logger
|
||||
{
|
||||
|
|
|
@ -29,13 +29,17 @@
|
|||
#include "serialization/parser.hpp"
|
||||
#include "upload_log.hpp"
|
||||
#include "wesconfig.h"
|
||||
|
||||
|
||||
#include "log.hpp"
|
||||
|
||||
#define TARGET_HOST "www.wesnoth.org"
|
||||
#define TARGET_URL "/cgi-bin/upload"
|
||||
#define TARGET_PORT 80
|
||||
|
||||
#define DBG_UPLD LOG_STREAM(debug, uploader)
|
||||
#define LOG_UPLD LOG_STREAM(info, uploader)
|
||||
#define WRN_UPLD LOG_STREAM(warn, uploader)
|
||||
#define ERR_UPLD LOG_STREAM(err, uploader)
|
||||
|
||||
struct upload_log::thread_info upload_log::thread_;
|
||||
upload_log::manager* upload_log::manager_ = 0;
|
||||
|
||||
|
@ -74,8 +78,10 @@ static void send_string(TCPsocket sock, const std::string &str)
|
|||
// compatibility.
|
||||
static int upload_logs(void *_ti)
|
||||
{
|
||||
DBG_UPLD << "attempting to upload game logs\n";
|
||||
TCPsocket sock = NULL;
|
||||
upload_log::thread_info *ti = static_cast<upload_log::thread_info*>(_ti);
|
||||
int numfiles = 0;
|
||||
|
||||
const char *header =
|
||||
"POST " TARGET_URL " HTTP/1.1\n"
|
||||
|
@ -101,8 +107,12 @@ static int upload_logs(void *_ti)
|
|||
contents = read_file(*i);
|
||||
|
||||
sock = SDLNet_TCP_Open(&ip);
|
||||
if (!sock)
|
||||
if (!sock) {
|
||||
ERR_UPLD << "error connecting to log server\n";
|
||||
break;
|
||||
} else {
|
||||
DBG_UPLD << "successfully connected to log server\n";
|
||||
}
|
||||
send_string(sock, header);
|
||||
send_string(sock, "Content-length: ");
|
||||
send_string(sock, lexical_cast<std::string>(contents.length()));
|
||||
|
@ -113,6 +123,7 @@ static int upload_logs(void *_ti)
|
|||
// Even if the server gives a bad response, we don't want to
|
||||
// be sending the same bad data over and over to the server.
|
||||
delete_directory(*i);
|
||||
numfiles++;
|
||||
|
||||
if (SDLNet_TCP_Recv(sock, response, sizeof(response))
|
||||
!= sizeof(response))
|
||||
|
@ -132,6 +143,8 @@ static int upload_logs(void *_ti)
|
|||
if (sock)
|
||||
SDLNet_TCP_Close(sock);
|
||||
ti->shutdown = true;
|
||||
DBG_UPLD << numfiles << " game logs successfully sent to server\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue