[Kimchi-devel] [PATCH][Wok 2/2] Allow wok.conf determine log file size

Ramon Medeiros ramonn at linux.vnet.ibm.com
Fri Jun 10 14:50:51 UTC 2016


Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 src/wok.conf.in      | 3 +++
 src/wok/config.py.in | 1 +
 src/wok/server.py    | 6 ++++--
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/wok.conf.in b/src/wok.conf.in
index 713c5a9..67dc75a 100644
--- a/src/wok.conf.in
+++ b/src/wok.conf.in
@@ -50,6 +50,9 @@
 # Logging level: debug, info, warning, error or critical
 #log_level = debug
 
+# Log file size (specify size in K, M or G)
+#log_size = 10M
+
 [authentication]
 # Authentication method, available option: pam, ldap.
 # method = pam
diff --git a/src/wok/config.py.in b/src/wok/config.py.in
index fd30fd6..1ca6f73 100644
--- a/src/wok/config.py.in
+++ b/src/wok/config.py.in
@@ -280,6 +280,7 @@ def _get_config():
     config.add_section("logging")
     config.set("logging", "log_dir", paths.log_dir)
     config.set("logging", "log_level", DEFAULT_LOG_LEVEL)
+    config.set("logging", "log_size", "10M")
 
     config_file = os.path.join(paths.conf_dir, 'wok.conf')
     if os.path.exists(config_file):
diff --git a/src/wok/server.py b/src/wok/server.py
index 6909b16..567364d 100644
--- a/src/wok/server.py
+++ b/src/wok/server.py
@@ -49,7 +49,7 @@ LOGROTATE_TEMPLATE = """
 ${log_dir}/*log {
     daily
     nomail
-    maxsize 10M
+    maxsize ${log_size}
     rotate 10
     nomissingok
     compress
@@ -153,7 +153,9 @@ class Server(object):
             # redefine logrotate configuration according to wok.conf
             data = Template(LOGROTATE_TEMPLATE)
             data = data.safe_substitute(log_dir=configParser.get("logging",
-                                        "log_dir"))
+                                        "log_dir"),
+                                        log_size=configParser.get("logging",
+                                        "log_size"))
 
             # Write file to be used for nginx.
             config_file = open(os.path.join(paths.logrotate_dir, "wokd"), "w")
-- 
2.5.5




More information about the Kimchi-devel mailing list