ithewei 6 tahun lalu
induk
melakukan
9dd2712280
4 mengubah file dengan 7 tambahan dan 12 penghapusan
  1. 0 3
      .gitignore
  2. 1 1
      README.md
  3. 2 0
      hmain.cpp
  4. 4 8
      main.cpp.tmpl

+ 0 - 3
.gitignore

@@ -27,6 +27,3 @@ dist
 
 # test
 test
-
-# Makefiles
-Makefile.*

+ 1 - 1
README.md

@@ -47,5 +47,5 @@ hw 是一套跨平台c++工具集,类名以H开头
 
 ```
 mv main.cpp.tmpl main.cpp
-make DIRS="."
+make
 ```

+ 2 - 0
hmain.cpp

@@ -97,6 +97,8 @@ int main_ctx_init(int argc, char** argv) {
     snprintf(g_main_ctx.pidfile, sizeof(g_main_ctx.pidfile), "%s/logs/%s.pid", g_main_ctx.run_path, g_main_ctx.program_name);
     snprintf(g_main_ctx.logfile, sizeof(g_main_ctx.confile), "%s/logs/%s.log", g_main_ctx.run_path, g_main_ctx.program_name);
 
+    hlog_set_file(g_main_ctx.logfile);
+
     g_main_ctx.oldpid = getpid_from_pidfile();
 #ifdef OS_UNIX
     if (kill(g_main_ctx.oldpid, 0) == -1 && errno == ESRCH) {

+ 4 - 8
main.cpp.tmpl

@@ -68,8 +68,9 @@ int parse_confile(const char* confile) {
     // logfile
     string str = g_conf_ctx.parser->GetValue("logfile");
     if (!str.empty()) {
-        hlog_set_file(str.c_str());
+        strncpy(g_main_ctx.logfile, str.c_str(), sizeof(g_main_ctx.logfile));
     }
+    hlog_set_file(g_main_ctx.logfile);
     // loglevel
     const char* szLoglevel = g_conf_ctx.parser->GetValue("loglevel").c_str();
     if (stricmp(szLoglevel, "VERBOSE") == 0) {
@@ -198,17 +199,12 @@ int main(int argc, char** argv) {
         exit(0);
     }
 
-    // logfile
-    hlog_set_file(g_main_ctx.logfile);
-
-    // confile
+    // g_conf_ctx
+    conf_ctx_init(&g_conf_ctx);
     const char* confile = get_arg("c");
     if (confile) {
         strncpy(g_main_ctx.confile, confile, sizeof(g_main_ctx.confile));
     }
-
-    // g_conf_ctx
-    conf_ctx_init(&g_conf_ctx);
     parse_confile(g_main_ctx.confile);
 
     // test