added new multi log system
[NeonServV5.git] / src / mysqlConn.c
index 4673c7dbe7c8767014ee2d5586a4fb872cca91d6..45ab1931dee8766b7e13c9a4a15da6cfa41fd3fc 100644 (file)
@@ -18,6 +18,7 @@
 #include "mysqlConn.h"
 #include "ConfigParser.h"
 #include "tools.h"
+#include "log.h"
 #define DATABASE_VERSION "20"
 
 static void show_mysql_error();
@@ -160,7 +161,8 @@ void init_mysql() {
                 }
             }
             fclose(f);
-        }
+        } else
+            printf_log("main", LOG_ERROR | LOG_MYSQL, "File not found: database.sql");
         f = fopen("database.defaults.sql", "r");
         if (f) {
             char line[4096];
@@ -175,7 +177,8 @@ void init_mysql() {
                 }
             }
             fclose(f);
-        }
+        } else
+            printf_log("main", LOG_ERROR | LOG_MYSQL, "File not found: database.defaults.sql");
         do { 
             MYSQL_RES *res = mysql_store_result(mysql_conn); 
             mysql_free_result(res); 
@@ -209,7 +212,7 @@ void init_mysql() {
             }
             fclose(f);
         } else
-            perror("database.sql missing!");
+            printf_log("main", LOG_ERROR | LOG_MYSQL, "File not found: database.upgrade.sql");
         do { 
             MYSQL_RES *res = mysql_store_result(mysql_conn); 
             mysql_free_result(res); 
@@ -232,7 +235,7 @@ void free_mysql() {
 static void show_mysql_error() {
     MYSQL *mysql_conn = get_mysql_conn();
     //show mysql_error()
-    putlog(LOGLEVEL_ERROR, "MySQL Error: %s\n", mysql_error(mysql_conn));
+    printf_log("main", LOG_ERROR | LOG_MYSQL, "Error: %s\n", mysql_error(mysql_conn));
 }
 
 void printf_mysql_query(const char *text, ...) {
@@ -246,7 +249,7 @@ void printf_mysql_query(const char *text, ...) {
     va_end(arg_list);
     if (pos < 0 || pos > (MYSQLMAXLEN - 2)) pos = MYSQLMAXLEN - 2;
     queryBuf[pos] = '\0';
-    putlog(LOGLEVEL_MYSQL, "MySQL: %s\n", queryBuf);
+    printf_log("main", LOG_MYSQL, "%s\n", queryBuf);
     if(mysql_query(mysql_conn, queryBuf)) {
         check_mysql();
         if(mysql_query(mysql_conn, queryBuf)) {
@@ -266,7 +269,7 @@ void printf_long_mysql_query(int len, const char *text, ...) {
     va_end(arg_list);
     if (pos < 0 || pos > (len - 2)) pos = len - 2;
     queryBuf[pos] = '\0';
-    putlog(LOGLEVEL_MYSQL, "MySQL: %s\n", queryBuf);
+    printf_log("main", LOG_MYSQL, "%s\n", queryBuf);
     if(mysql_query(mysql_conn, queryBuf)) {
         check_mysql();
         if(mysql_query(mysql_conn, queryBuf)) {