Author: baufo
Date: Fri Sep 12 20:17:52 2008
New Revision: 29420

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29420&view=rev
Log:
Adding user_handler log domain.

Modified:
    trunk/src/log.cpp
    trunk/src/log.hpp
    trunk/src/server/forum_user_handler.cpp
    trunk/src/server/user_handler.hpp

Modified: trunk/src/log.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/log.cpp?rev=29420&r1=29419&r2=29420&view=diff
==============================================================================
--- trunk/src/log.cpp (original)
+++ trunk/src/log.cpp Fri Sep 12 20:17:52 2008
@@ -53,7 +53,8 @@
        engine("engine"), network("network"), mp_server("server"),
        filesystem("filesystem"), audio("audio"), notifs("notifs"),
        replay("replay"), help("help"), gui("gui"), gui_parse("gui_parse"),
-       gui_draw("gui_draw"), gui_event("gui_event"), editor("editor"), 
wml("wml");
+       gui_draw("gui_draw"), gui_event("gui_event"), editor("editor"), 
wml("wml"),
+       mp_user_handler("user_handler");
 
 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=29420&r1=29419&r2=29420&view=diff
==============================================================================
--- trunk/src/log.hpp (original)
+++ trunk/src/log.hpp Fri Sep 12 20:17:52 2008
@@ -67,7 +67,7 @@
 extern logger err, warn, info, debug;
 extern log_domain general, ai,cache, config, display, engine, network, 
mp_server,
        filesystem, audio, notifs, replay, help, gui, gui_parse, gui_draw,
-       gui_event, editor, wml;
+       gui_event, editor, wml, mp_user_handler;
 
 class scope_logger
 {

Modified: trunk/src/server/forum_user_handler.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/forum_user_handler.cpp?rev=29420&r1=29419&r2=29420&view=diff
==============================================================================
--- trunk/src/server/forum_user_handler.cpp (original)
+++ trunk/src/server/forum_user_handler.cpp Fri Sep 12 20:17:52 2008
@@ -16,7 +16,7 @@
        try {
                db_interface_.connect(db_name_.c_str(), db_host_.c_str(), 
db_user_.c_str(), db_password_.c_str());
        } catch(...) {
-                std::cerr << "FUH: ERROR: Could not connect to database: " << 
db_interface_.error() << std::endl;
+                ERR_UH << "Could not connect to database: " << 
db_interface_.error() << std::endl;
        }
 }
 
@@ -25,7 +25,6 @@
 }
 
 std::string fuh::set_detail_for_user(const std::string& name, const 
std::string& detail, const std::string& value) {
-       std::cout <<  std::string("UPDATE " + db_users_table_ + " SET " + 
detail + "='" + name + "' WHERE username='" + name + "'") << std::endl;
        return std::string("UPDATE " + db_users_table_ + " SET " + detail + 
"='" + value + "' WHERE username='" + name + "'");
 }
 
@@ -49,12 +48,12 @@
 
        //Check if we are connected
        if(!(db_interface_.connected())) {
-               std::cerr << "FUH: not connected to database, reconnecting..." 
<< std::endl;
+               WRN_UH << "not connected to database, reconnecting..." << 
std::endl;
                //Try to reconnect
                try {
                        db_interface_.connect(db_name_.c_str(), 
db_host_.c_str(), db_user_.c_str(), db_password_.c_str());
                } catch(...) {
-                        std::cerr << "FUH: ERROR: Could not connect to 
database: " << db_interface_.error() << std::endl;
+                        ERR_UH << "Could not connect to database: " << 
db_interface_.error() << std::endl;
                }
        }
 
@@ -72,20 +71,20 @@
        // Set an alphabet-like string for use in encrytpion algorithm   
        std::string 
itoa64("./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
 
-       // Retrive users' password as hash
+       // Retrieve users' password as hash
 
        std::string hash;
 
        try {
                hash = get_hash(name);
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve hash for user '" << name << "' :" 
<< e.message << std::endl;
                return false;
        }
 
        // Check hash prefix, if different than $H$ hash is invalid
        if(hash.substr(0,3) != "$H$") {
-               std::cerr << "ERROR: Invalid hash prefix for user '" << name << 
"'" << std::endl;
+               ERR_UH << "Invalid hash prefix for user '" << name << "'" << 
std::endl;
                return false;
        }
 
@@ -115,7 +114,7 @@
        try {
                hash = get_hash(name);
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve hash for user '" << name << "' :" 
<< e.message << std::endl;
                return "";
        }
 
@@ -154,7 +153,7 @@
        try {
                return db_query(get_detail_for_user(name, 
"username")).num_rows() > 0;
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not execute test query for user '" << 
e.message << std::endl;
                // If the database is down just let all usernames log in
                return false;
        }
@@ -177,7 +176,7 @@
        try {
        db_query(set_detail_for_user(user, "user_lastvisit", ss.str()));
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not set last visit for user '" << e.message << 
std::endl;
        }
 }
 
@@ -185,7 +184,7 @@
        try {
                return db_query_to_string(get_detail_for_user(user, 
"user_password"));
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve password for user '" << e.message 
<< std::endl;
                return time_t(0);
        }
 }
@@ -194,7 +193,7 @@
        try {
                return db_query_to_string(get_detail_for_user(user, 
"user_email"));
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve email for user '" << e.message << 
std::endl;
                return time_t(0);
        }
 }
@@ -260,7 +259,7 @@
                int time_int = 
atoi(db_query_to_string(get_detail_for_user(user, "user_lastvisit")).c_str());
                return time_t(time_int);
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve last visit for user '" << 
e.message << std::endl;
                return time_t(0);
        }
 }
@@ -270,7 +269,7 @@
                int time_int = 
atoi(db_query_to_string(get_detail_for_user(user, "user_regdate")).c_str());
                return time_t(time_int);
        } catch (error e) {
-               std::cerr << "FUH: ERROR: " << e.message << std::endl;
+               ERR_UH << "Could not retrieve registration date for user '" << 
e.message << std::endl;
                return time_t(0);
        }
 }

Modified: trunk/src/server/user_handler.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/user_handler.hpp?rev=29420&r1=29419&r2=29420&view=diff
==============================================================================
--- trunk/src/server/user_handler.hpp (original)
+++ trunk/src/server/user_handler.hpp Fri Sep 12 20:17:52 2008
@@ -4,6 +4,7 @@
 #include "../global.hpp"
 
 #include "../config.hpp"
+#include "../log.hpp"
 
 #include <vector>
 #include <string>
@@ -14,6 +15,11 @@
 #include <sstream>
 
 #include "mail.hpp"
+
+#define ERR_UH LOG_STREAM(err, mp_user_handler)
+#define WRN_UH LOG_STREAM(warn, mp_user_handler)
+#define LOG_UH LOG_STREAM(info, mp_user_handler)
+#define DBG_UH LOG_STREAM(debug, mp_user_handler)
 
 //! @class An interface class to handle nick registration
 //! To activate it put a [user_handler] section into the


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

Reply via email to