From: Rafal Somla Date: March 18 2011 4:11pm Subject: bzr commit into mysql-5.5 branch (rafal.somla:3375) List-Archive: http://lists.mysql.com/commits/133339 Message-Id: <201103181609.p2IG9q7X005136@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0428670525==" --===============0428670525== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At D:/source/bzr2/mysql-5.5 based on revid:rafal.somla@stripped 3375 Rafal Somla 2011-03-18 Change error logging infrastructure so that: 1. No errors are logged in a production build. 2. In debug builds no errors and no debug messages are logged by default - this can be overriden with AUTHENTICATION_WIN_LOG environment variable. 3. AUTHENTICATION_WIN_LOG=yes means that error/warning/info messages are logged. Value of debug means that also debug messages are logged. modified: libmysql/authentication_win/CMakeLists.txt libmysql/authentication_win/common.h libmysql/authentication_win/handshake_client.cc libmysql/authentication_win/log_client.cc === modified file 'libmysql/authentication_win/CMakeLists.txt' --- a/libmysql/authentication_win/CMakeLists.txt 2011-03-18 14:43:08 +0000 +++ b/libmysql/authentication_win/CMakeLists.txt 2011-03-18 16:11:14 +0000 @@ -18,6 +18,7 @@ # ADD_DEFINITIONS(-DSECURITY_WIN32) +ADD_DEFINITIONS(-DDEBUG_ERRROR_LOG) # no error logging in production builds SET(HEADERS common.h handshake.h) SET(PLUGIN_SOURCES plugin_client.cc handshake_client.cc log_client.cc common.cc handshake.cc) === modified file 'libmysql/authentication_win/common.h' --- a/libmysql/authentication_win/common.h 2011-03-18 14:43:08 +0000 +++ b/libmysql/authentication_win/common.h 2011-03-18 16:11:14 +0000 @@ -48,6 +48,8 @@ struct error_log_level #define DBUG_ASSERT(X) do {} while (0) #endif +extern "C" int opt_auth_win_client_log; + /* Note1: Double level of indirection in definition of DBUG_PRINT allows to temporary redefine or disable DBUG_PRINT macro and then easily return to @@ -64,9 +66,10 @@ struct error_log_level #ifndef DBUG_OFF #define DBUG_PRINT_DO(Keyword, Msg) \ do { \ + if (2 > opt_auth_win_client_log) break; \ fprintf(stderr, "winauth: %s: ", Keyword); \ debug_msg Msg; \ - } while(0) + } while (0) #else #define DBUG_PRINT_DO(K, M) do {} while (0) #endif @@ -74,8 +77,11 @@ struct error_log_level #undef DBUG_PRINT #define DBUG_PRINT(Keyword, Msg) DBUG_PRINT_DO(Keyword, Msg) +#if defined(DEBUG_ERROR_LOG) && defined(DBUG_OFF) +#define ERROR_LOG(Level, Msg) do {} while (0) +#else #define ERROR_LOG(Level, Msg) error_log_print< error_log_level::Level > Msg - +#endif inline void debug_msg(const char *fmt, ...) === modified file 'libmysql/authentication_win/handshake_client.cc' --- a/libmysql/authentication_win/handshake_client.cc 2011-03-18 14:43:08 +0000 +++ b/libmysql/authentication_win/handshake_client.cc 2011-03-18 16:11:14 +0000 @@ -178,8 +178,6 @@ Blob Handshake_client::process_data(cons /**********************************************************************/ -bool opt_auth_win_client_log= false; - /** Perform authentication handshake from client side. @@ -205,12 +203,14 @@ int win_auth_handshake_client(MYSQL_PLUG */ { const char *opt= getenv("AUTHENTICATION_WIN_LOG"); - bool opt_val= opt ? atoi(opt) : 0; + int opt_val= opt ? atoi(opt) : 0; if (opt && !opt_val) { - opt_val= opt_val || !strncasecmp("on", opt, 2); - opt_val= opt_val || !strncasecmp("yes", opt, 3); - opt_val= opt_val || !strncasecmp("true", opt, 4); + if (!strncasecmp("on", opt, 2)) opt_val= 1; + if (!strncasecmp("yes", opt, 3)) opt_val= 1; + if (!strncasecmp("true", opt, 4)) opt_val= 1; + if (!strncasecmp("debug", opt, 5)) opt_val= 2; + if (!strncasecmp("dbug", opt, 4)) opt_val= 2; } opt_auth_win_client_log= opt_val; } === modified file 'libmysql/authentication_win/log_client.cc' --- a/libmysql/authentication_win/log_client.cc 2011-03-18 14:43:08 +0000 +++ b/libmysql/authentication_win/log_client.cc 2011-03-18 16:11:14 +0000 @@ -16,7 +16,19 @@ #include #include "common.h" -extern bool opt_auth_win_client_log; // defined in handshake_client.cc +/** + This option is set in win_auth_handshake_client() function + in handshake_client.cc. + + Values: + 0 - no logging + 1 - log error/warning/info messages + 2 - also log debug messages + + Note: No error or debug messages are logged in production code + (see logging macros in common.h). +*/ +int opt_auth_win_client_log= 0; // Client-side logging function @@ -24,14 +36,8 @@ extern bool opt_auth_win_client_log; // void error_log_vprint(error_log_level::type level, const char *fmt, va_list args) { - /* - Unless this is a debug build, do not log anything if auth_win_client_log - option is not enabled. - */ -#ifdef DBUG_OFF - if (!opt_auth_win_client_log) + if (0 == opt_auth_win_client_log) return; -#endif const char *level_string= ""; --===============0428670525== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/rafal.somla@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: rafal.somla@stripped # target_branch: file:///D:/rafal/winauth/bug59780/mysql-5.5/ # testament_sha1: db8baa68a16234ea2e4f5cc148e0a626d83c524f # timestamp: 2011-03-18 17:11:28 +0100 # source_branch: D:/rafal/winauth/bug59780/mysql-5.5 # base_revision_id: rafal.somla@stripped\ # sprtai7cxwltw8m8 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTnrjeEABDtfgHAweXf////n n4S////6YAeOF9VN9gAajMAbO3TrVTcMip6TKPT0J6QmGkeibUaaD1DQA00BoAGhwDCMJpiGAQDI AYRpkyYRgIaHAMIwmmIYBAMgBhGmTJhGAhoJEgTQqe1U/0RiU9EGn+pQZANGQA9TIG1NACKlM1Tw mqafqbJBkmCGEfqD1EabUYQGQYCCSQINABBok08k0ZU8KZk1G0QzRqNpBtIPEGGb2ryzXLc776CC Jh5qnZm0eDWrsTx4HZ0wBzhVQRYu56x7Twu+A+PJ3g5TNmPo6fWvfJE2izSVkcLcJUh0r2UikW7I rhohdvp/aQhURubaG0DhxKO+LkPSuMbr+4FPOEwbGNobAx8fL0IOOTxvfIrFWNnsXUzCvRh4sDk1 zdy9LzMpGVIm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