Author: boucman
Date: Fri Apr 17 15:02:02 2009
New Revision: 34980

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34980&view=rev
Log:
put stat upload logs in a separate logdomain, patch by corn

Modified:
    trunk/changelog
    trunk/src/log.cpp
    trunk/src/log.hpp
    trunk/src/upload_log.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34980&r1=34979&r2=34980&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Fri Apr 17 15:02:02 2009
@@ -4,6 +4,7 @@
      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

Modified: trunk/src/log.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/log.cpp?rev=34980&r1=34979&r2=34980&view=diff
==============================================================================
--- trunk/src/log.cpp (original)
+++ trunk/src/log.cpp Fri Apr 17 15:02:02 2009
@@ -54,7 +54,7 @@
        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())
 {

Modified: trunk/src/log.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/log.hpp?rev=34980&r1=34979&r2=34980&view=diff
==============================================================================
--- trunk/src/log.hpp (original)
+++ trunk/src/log.hpp Fri Apr 17 15:02:02 2009
@@ -68,7 +68,7 @@
 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
 {

Modified: trunk/src/upload_log.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/upload_log.cpp?rev=34980&r1=34979&r2=34980&view=diff
==============================================================================
--- trunk/src/upload_log.cpp (original)
+++ trunk/src/upload_log.cpp Fri Apr 17 15:02:02 2009
@@ -29,12 +29,16 @@
 #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 @@
 // 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 @@
                                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 @@
                                // 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 @@
        if (sock)
                SDLNet_TCP_Close(sock);
        ti->shutdown = true;
+       DBG_UPLD << numfiles << " game logs successfully sent to server\n";
+       
        return 0;
 }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to