[tor-commits] [nyx/master] Fix logging string resources

atagar at torproject.org atagar at torproject.org
Tue Jun 7 17:30:03 UTC 2016


commit 8b6970bf60f4ca9c59d207a1c064744debb4e8ca
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Jun 7 10:27:42 2016 -0700

    Fix logging string resources
    
    While adding a warning for invalid events realized that most of our logging in
    this module is incorrect.
---
 nyx/log.py               | 11 ++++++-----
 nyx/settings/strings.cfg |  4 ++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/nyx/log.py b/nyx/log.py
index 255fac7..ccc11e0 100644
--- a/nyx/log.py
+++ b/nyx/log.py
@@ -193,6 +193,7 @@ def listen_for_events(listener, events):
     try:
       controller.add_event_listener(listener, event_type)
     except stem.ProtocolError:
+      warn('panel.log.unsupported_event', event = event_type)
       tor_events.remove(event_type)
 
   return sorted(tor_events.union(nyx_events))
@@ -384,11 +385,11 @@ class LogFileOutput(object):
           os.makedirs(path_dir)
 
         self._file = open(path, 'a')
-        notice('nyx %s opening log file (%s)' % (nyx.__version__, path))
+        notice('panel.log.opening_log_file', version = nyx.__version__, path = path)
       except IOError as exc:
-        error('Unable to write to log file: %s' % exc.strerror)
+        error('msg.panel.log.unable_to_open_log_file', reason = exc.strerror)
       except OSError as exc:
-        error('Unable to write to log file: %s' % exc)
+        error('msg.panel.log.unable_to_open_log_file', reason = exc)
 
   def write(self, msg):
     if self._file:
@@ -396,7 +397,7 @@ class LogFileOutput(object):
         self._file.write(msg + '\n')
         self._file.flush()
       except IOError as exc:
-        error('Unable to write to log file: %s' % exc.strerror)
+        error('msg.panel.log.unable_to_open_log_file', reason = exc.strerror)
         self._file = None
 
 
@@ -434,7 +435,7 @@ class LogFilters(object):
         if len(self._past_filters) > self._max_filters:
           self._past_filters.popitem(False)
       except re.error as exc:
-        notice('Invalid regular expression pattern (%s): %s' % (exc, regex))
+        notice('panel.log.bad_filter_regex', reason = exc, pattern = regex)
 
   def selection(self):
     return self._selected
diff --git a/nyx/settings/strings.cfg b/nyx/settings/strings.cfg
index e4c7029..9179519 100644
--- a/nyx/settings/strings.cfg
+++ b/nyx/settings/strings.cfg
@@ -25,6 +25,10 @@ msg.panel.header.fd_used_at_ninety_percent Tor's file descriptor usage is at {pe
 msg.panel.graphing.prepopulation_successful Bandwidth graph has information for the last {duration}
 msg.panel.graphing.bw_event_cache_malformed Tor's 'GETINFO bw-event-cache' provided malformed output: {response}
 msg.panel.log.read_from_log_file Read {count} entries from tor's log file: {path} (read limit: {read_limit}, runtime: {runtime})
+msg.panel.log.unsupported_event {event} isn't an event tor spupports
+msg.panel.log.bad_filter_regex Invalid regular expression pattern ({reason}): {pattern}
+msg.panel.log.opening_log_file nyx {version} opening log file ({path})
+msg.panel.log.unable_to_open_log_file Unable to write to log file: {reason}
 msg.panel.torrc.unable_to_find_torrc Unable to determine our torrc location: {error}
 msg.panel.torrc.unable_to_load_torrc Unable to read our torrc: {error}
 





More information about the tor-commits mailing list