ithewei 6 éve
szülő
commit
2c5b6e70c9
2 módosított fájl, 13 hozzáadás és 11 törlés
  1. 11 9
      main.cpp.tmpl
  2. 2 2
      utils/hmain.cpp

+ 11 - 9
main.cpp.tmpl

@@ -74,24 +74,26 @@ int parse_confile(const char* confile) {
     hlog_set_file(g_main_ctx.logfile);
     // loglevel
     const char* szLoglevel = g_conf_ctx.parser->GetValue("loglevel").c_str();
+    int loglevel = LOG_LEVEL_INFO;
     if (stricmp(szLoglevel, "VERBOSE") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_VERBOSE;
+        loglevel = LOG_LEVEL_VERBOSE;
     } else if (stricmp(szLoglevel, "DEBUG") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_DEBUG;
+        loglevel = LOG_LEVEL_DEBUG;
     } else if (stricmp(szLoglevel, "INFO") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_INFO;
+        loglevel = LOG_LEVEL_INFO;
     } else if (stricmp(szLoglevel, "WARN") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_WARN;
+        loglevel = LOG_LEVEL_WARN;
     } else if (stricmp(szLoglevel, "ERROR") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_ERROR;
+        loglevel = LOG_LEVEL_ERROR;
     } else if (stricmp(szLoglevel, "FATAL") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_FATAL;
+        loglevel = LOG_LEVEL_FATAL;
     } else if (stricmp(szLoglevel, "SILENT") == 0) {
-        g_conf_ctx.loglevel = LOG_LEVEL_SILENT;
+        loglevel = LOG_LEVEL_SILENT;
     } else {
-        g_conf_ctx.loglevel = LOG_LEVEL_VERBOSE;
+        loglevel = LOG_LEVEL_INFO;
     }
-    hlog_set_level(g_conf_ctx.loglevel);
+    g_conf_ctx.loglevel = loglevel;
+    hlog_set_level(loglevel);
     // log_filesize
     str = g_conf_ctx.parser->GetValue("log_filesize");
     if (!str.empty()) {

+ 2 - 2
utils/hmain.cpp

@@ -290,7 +290,7 @@ void setproctitle(const char* title) {
 int create_pidfile() {
     FILE* fp = fopen(g_main_ctx.pidfile, "w");
     if (fp == NULL) {
-        hloge("fopen('%s') error: %d\n", g_main_ctx.pidfile, errno);
+        hloge("fopen('%s') error: %d", g_main_ctx.pidfile, errno);
         return -1;
     }
 
@@ -311,7 +311,7 @@ void delete_pidfile() {
 pid_t getpid_from_pidfile() {
     FILE* fp = fopen(g_main_ctx.pidfile, "r");
     if (fp == NULL) {
-        hloge("fopen('%s') error: %d\n", g_main_ctx.pidfile, errno);
+        hloge("fopen('%s') error: %d", g_main_ctx.pidfile, errno);
         return -1;
     }
     char pid[64];