ithewei 6 роки тому
батько
коміт
4b1deecfb4
3 змінених файлів з 23 додано та 0 видалено
  1. 1 0
      etc/httpd.conf
  2. 1 0
      etc/test.conf
  3. 21 0
      main.cpp.tmpl

+ 1 - 0
etc/httpd.conf

@@ -4,6 +4,7 @@
 # loglevel = [VERBOSE,DEBUG,INFO,WARN,ERROR,FATAL,SILENT]
 loglevel = INFO
 log_remain_days = 3
+log_filesize = 16M
 
 # worker_processes = 4
 # auto = ncpu

+ 1 - 0
etc/test.conf

@@ -4,6 +4,7 @@
 # loglevel = [VERBOSE,DEBUG,INFO,WARN,ERROR,FATAL,SILENT]
 loglevel = DEBUG
 log_remain_days = 3
+log_filesize = 16M
 
 # worker_processes = 4
 # auto = ncpu

+ 21 - 0
main.cpp.tmpl

@@ -92,6 +92,27 @@ int parse_confile(const char* confile) {
         g_conf_ctx.loglevel = LOG_LEVEL_VERBOSE;
     }
     hlog_set_level(g_conf_ctx.loglevel);
+    // log_filesize
+    str = g_conf_ctx.parser->GetValue("log_filesize");
+    if (!str.empty()) {
+        int num = atoi(str.c_str());
+        if (num > 0) {
+            // 16 16M 16MB
+            const char* p = str.c_str() + str.size() - 1;
+            char unit;
+            if (*p >= '0' && *p <= '9') unit = 'M';
+            else if (*p == 'B')         unit = *(p-1);
+            else                        unit = *p;
+            unsigned long long filesize = num;
+            switch (unit) {
+            case 'K': filesize <<= 10; break;
+            case 'M': filesize <<= 20; break;
+            case 'G': filesize <<= 30; break;
+            default:  filesize <<= 20; break;
+            }
+            hlog_set_max_filesize(filesize);
+        }
+    }
     // log_remain_days
     str = g_conf_ctx.parser->GetValue("log_remain_days");
     if (!str.empty()) {