[tor-commits] [stem/master] Don't log debug messages for multi-line config options

atagar at torproject.org atagar at torproject.org
Mon Feb 1 04:21:04 UTC 2016


commit 1b4f9dba0716982c7f942f66d28e8d6d622ccce1
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jan 31 12:22:00 2016 -0800

    Don't log debug messages for multi-line config options
    
    Our config module supports multi-line strings but these cause us to log debug
    messages like the following...
    
      01/31/2016 12:15:22 [DEBUG] Config entry 'config_options.Bridge.description'
      is expected to be of the format 'Key Value', defaulting to
      'config_options.Bridge.description' -> ''
    
    Just a bug where we logged this warning before we had the handling for them. On
    reflection though this message doesn't have any value so simply dropping it.
---
 stem/util/conf.py | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/stem/util/conf.py b/stem/util/conf.py
index 134766c..a2763eb 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -512,14 +512,10 @@ class Config(object):
 
         # parse the key/value pair
         if line:
-          try:
+          if ' ' in line:
             key, value = line.split(' ', 1)
-            value = value.strip()
-          except ValueError:
-            log.debug("Config entry '%s' is expected to be of the format 'Key Value', defaulting to '%s' -> ''" % (line, line))
-            key, value = line, ''
-
-          if not value:
+            self.set(key, value.strip(), False)
+          else:
             # this might be a multi-line entry, try processing it as such
             multiline_buffer = []
 
@@ -529,10 +525,9 @@ class Config(object):
               multiline_buffer.append(content)
 
             if multiline_buffer:
-              self.set(key, '\n'.join(multiline_buffer), False)
-              continue
-
-          self.set(key, value, False)
+              self.set(line, '\n'.join(multiline_buffer), False)
+            else:
+              self.set(line, '', False)  # default to a key => '' mapping
 
   def save(self, path = None):
     """





More information about the tor-commits mailing list