[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] Add 2 conf opts for logging to file, but not used yet



commit d111af98e18a176590bffd9f80cb8c0b7ca3601b
Author: Matt Traudt <sirmatt@xxxxxxx>
Date:   Wed Jul 4 11:32:18 2018 -0400

    Add 2 conf opts for logging to file, but not used yet
---
 sbws/config.default.ini | 7 +++++++
 sbws/util/config.py     | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/sbws/config.default.ini b/sbws/config.default.ini
index dbe46a2..d9e2622 100644
--- a/sbws/config.default.ini
+++ b/sbws/config.default.ini
@@ -87,6 +87,13 @@ min_relays = 50
 to_file = yes
 # Whether or not to log to stdout
 to_stdout = no
+# If logging to file, how large (in bytes) should the file be allowed to get
+# before rotating to a new one. 10485760 is 10 MiB. If zero or number of
+# backups is zero, never rotate the log file.
+to_file_max_bytes = 10485760
+# If logging to file, how many backups to keep. If zero or max bytes is zero,
+# never rotate the log file.
+to_file_num_backups = 50
 # Level to log at. Debug, info, warning, error, critical.
 level = info
 to_file_level = ${level}
diff --git a/sbws/util/config.py b/sbws/util/config.py
index bf73540..8953d92 100644
--- a/sbws/util/config.py
+++ b/sbws/util/config.py
@@ -282,8 +282,13 @@ def _validate_logging(conf):
         'to_file': {},
         'to_stdout': {},
     }
+    ints = {
+        'to_file_max_bytes': {'minimum': 0, 'maximum': None},
+        'to_file_num_backups': {'minimum': 0, 'maximum': None},
+    }
     unvalidated = ['format', 'to_file_format', 'to_stdout_format']
-    all_valid_keys = list(bools.keys()) + list(enums.keys()) + unvalidated
+    all_valid_keys = list(bools.keys()) + list(enums.keys()) + \
+        list(ints.keys()) + unvalidated
     errors.extend(_validate_section_keys(conf, sec, all_valid_keys, err_tmpl))
     errors.extend(_validate_section_bools(conf, sec, bools, err_tmpl))
     errors.extend(_validate_section_enums(conf, sec, enums, err_tmpl))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits