[tor-commits] [nyx/master] Alias ERR for ERROR and WARN for WARNING

atagar at torproject.org atagar at torproject.org
Mon Oct 30 05:57:38 UTC 2017


commit e0a813df6ca3e92acce77a14fc94acd66fb9f323
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Oct 29 20:57:23 2017 -0700

    Alias ERR for ERROR and WARN for WARNING
    
    Fixing a couple easy to make gotchas in our --log argument. It's especially
    confusing becuase nyx expected 'NYX_WARNING' whereas it displayed 'NYX_WARN'.
---
 nyx/panel/log.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index c29f21e..94788a7 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -43,6 +43,16 @@ CONFIG = conf.config_dict('nyx', {
   'write_logs_to': '',
 }, conf_handler)
 
+# Users may understanably mix up 'WARN/WARNING' and 'ERR/ERROR' in their --log
+# argument or config, so fixing those.
+
+EVENT_ALIASES = {
+  'WARNING': 'WARN',
+  'ERROR': 'ERR',
+  'NYX_WARN': 'NYX_WARNING',
+  'NYX_ERR': 'NYX_ERROR',
+}
+
 UPDATE_RATE = 0.7
 
 # The height of the drawn content is estimated based on the last time we redrew
@@ -70,6 +80,12 @@ class LogPanel(nyx.panel.DaemonPanel):
     nyx.panel.DaemonPanel.__init__(self, UPDATE_RATE)
 
     logged_events = CONFIG['logged_events'].split(',')
+
+    for alias, actual_event in EVENT_ALIASES.items():
+      if alias in logged_events:
+        logged_events.remove(alias)
+        logged_events.append(actual_event)
+
     tor_events = tor_controller().get_info('events/names', '').split()
     invalid_events = list(filter(lambda event: not event.startswith('NYX_') and event not in tor_events, logged_events))
 





More information about the tor-commits mailing list