diff --git a/src/chassis-sql-log.c b/src/chassis-sql-log.c index f597270..cbfdc56 100644 --- a/src/chassis-sql-log.c +++ b/src/chassis-sql-log.c @@ -2,6 +2,7 @@ #include "network-mysqld-packet.h" #include #include +#include const COM_STRING com_command_name[]={ { C("Sleep") }, @@ -341,6 +342,14 @@ sql_log_thread_start(struct sql_log_mgr *mgr) { if (mgr->sql_log_path == NULL) { mgr->sql_log_path = g_strdup(SQL_LOG_DEF_PATH); } + int result = access(mgr->sql_log_path, F_OK); + if (result != 0) { + g_message("sql log path is not exist, try to mkdir"); + result = mkdir(mgr->sql_log_path, 0660); + if (result != 0) { + g_message("mkdir(%s) failed", mgr->sql_log_path); + } + } if (mgr->sql_log_fullname == NULL) { mgr->sql_log_fullname = g_strdup_printf("%s/%s.%s", mgr->sql_log_path, mgr->sql_log_filename, SQL_LOG_DEF_SUFFIX); } diff --git a/src/mysql-proxy-cli.c b/src/mysql-proxy-cli.c index cd0508e..d79f3ce 100644 --- a/src/mysql-proxy-cli.c +++ b/src/mysql-proxy-cli.c @@ -1162,7 +1162,7 @@ main_cmdline(int argc, char **argv) if (frontend->sql_log_path) { srv->sql_mgr->sql_log_path = g_strdup(frontend->sql_log_path); } else if(frontend->base_dir) { - srv->sql_mgr->sql_log_path = g_strdup(frontend->base_dir); + srv->sql_mgr->sql_log_path = g_strdup_printf("%s/logs", frontend->base_dir); } if (frontend->sql_log_maxsize >= 0) { srv->sql_mgr->sql_log_maxsize = frontend->sql_log_maxsize;