#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 <my_global.h>
#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= "";
Attachment: [text/bzr-bundle] bzr/rafal.somla@oracle.com-20110318161114-basaw19ty46vhhfj.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5 branch (rafal.somla:3375) | Rafal Somla | 18 Mar |