1
diff -Nur a/client/client_priv.h b/client/client_priv.h
2
--- a/client/client_priv.h 2010-08-08 14:12:42.229338865 +0400
3
+++ b/client/client_priv.h 2010-08-08 14:12:43.068089277 +0400
5
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
6
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
7
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
11
OPT_MAX_CLIENT_OPTION,
12
diff -Nur a/client/mysql.cc b/client/mysql.cc
13
--- a/client/mysql.cc 2010-08-08 14:12:42.229338865 +0400
14
+++ b/client/mysql.cc 2010-08-08 14:12:43.488088866 +0400
16
#include "my_readline.h"
23
#if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H)
26
default_charset_used= 0, opt_secure_auth= 0,
27
default_pager_set= 0, opt_sigint_ignore= 0,
28
show_warnings= 0, executing_query= 0, interrupted_query= 0,
30
+ opt_syslog=0, ignore_spaces= 0;
31
static my_bool debug_info_flag, debug_check_flag;
32
static my_bool column_types_flag;
33
static my_bool preserve_comments= 0;
35
void tee_fputs(const char *s, FILE *file);
36
void tee_puts(const char *s, FILE *file);
37
void tee_putc(int c, FILE *file);
38
+void write_syslog(char *line);
39
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
40
/* The names of functions that actually do the manipulation. */
41
static int get_options(int argc,char **argv);
42
@@ -1568,6 +1572,10 @@
43
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
44
&show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG,
47
+ {"syslog", OPT_SYSLOG, "Logs all queries to syslog", 0, 0, 0, GET_NO_ARG,
48
+ NO_ARG, 0, 0, 0, 0, 0, 0},
50
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
53
@@ -1691,6 +1699,12 @@
58
+ /*if (connect_flag == CLIENT_INTERACTIVE){
59
+ printf("Logging queries to syslog.\n");
64
#ifdef EMBEDDED_LIBRARY
66
@@ -2067,6 +2081,39 @@
67
DBUG_RETURN((COMMANDS *) 0);
70
+void write_syslog(char *line){
74
+ for (i=0;i < strlen(line); i++){
75
+ buff[buff_pos] = line[i];
77
+ if (buff_pos >= 900){
80
+ syslog(LOG_INFO, "SYSTEM_USER:%s, MYSQL_USER:%s, CONNECTION_ID:%lu, DB_SERVER:%s, DB:%s, QUERY:%s",
81
+ getenv("SUDO_USER") ? getenv("SUDO_USER") :
82
+ getenv("USER") ? getenv("USER") : "--",
83
+ current_user ? current_user : "--",
84
+ mysql_thread_id(&mysql),
85
+ current_host ? current_host : "--",
86
+ current_db ? current_db : "--",
91
+ buff[buff_pos] = NULL;
92
+ syslog(LOG_INFO, "SYSTEM_USER:%s, MYSQL_USER:%s, CONNECTION_ID:%lu, DB_SERVER:%s, DB:%s, QUERY:%s",
93
+ getenv("SUDO_USER") ? getenv("SUDO_USER") :
94
+ getenv("USER") ? getenv("USER") : "--",
95
+ current_user ? current_user : "--",
96
+ mysql_thread_id(&mysql),
97
+ current_host ? current_host : "--",
98
+ current_db ? current_db : "--",
104
static bool add_line(String &buffer,char *line,char *in_string,
105
bool *ml_comment, bool truncated)
106
@@ -3038,6 +3085,11 @@
111
+ if (opt_syslog && buffer->length() && connect_flag == CLIENT_INTERACTIVE){
112
+ write_syslog(buffer->c_ptr());