[tor-commits] [nyx/master] Don't provide dates when writing logs to files

atagar at torproject.org atagar at torproject.org
Tue May 5 05:42:06 UTC 2015


commit c1c1581b5d9a8435703822b42e806ad4b2693ad2
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Apr 11 16:26:09 2015 -0700

    Don't provide dates when writing logs to files
    
    Tor doesn't provide dates (#15607) so we provide made up information for
    prepopulated events. Might as well just not provide dates at all until tor
    improves this.
---
 nyx/log_panel.py |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/nyx/log_panel.py b/nyx/log_panel.py
index ddf2c6e..cdaca17 100644
--- a/nyx/log_panel.py
+++ b/nyx/log_panel.py
@@ -283,7 +283,7 @@ class LogEntry():
     self.color = CONFIG['attr.log_color'].get(event_type, 'white')
 
   @lru_cache()
-  def get_display_message(self, include_date = False):
+  def get_display_message(self):
     """
     Provides the entry's message for the log.
 
@@ -291,13 +291,8 @@ class LogEntry():
       include_date - appends the event's date to the start of the message
     """
 
-    if include_date:
-      entry_time = time.localtime(self.timestamp)
-      time_label = '%i/%i/%i %02i:%02i:%02i' % (entry_time[1], entry_time[2], entry_time[0], entry_time[3], entry_time[4], entry_time[5])
-      return '%s [%s] %s' % (time_label, self.type, self.msg)
-    else:
-      entry_time = time.localtime(self.timestamp)
-      return '%02i:%02i:%02i [%s] %s' % (entry_time[3], entry_time[4], entry_time[5], self.type, self.msg)
+    entry_time = time.localtime(self.timestamp)
+    return '%02i:%02i:%02i [%s] %s' % (entry_time[3], entry_time[4], entry_time[5], self.type, self.msg)
 
 
 class LogPanel(panel.Panel, threading.Thread, logging.Handler):
@@ -491,7 +486,7 @@ class LogPanel(panel.Panel, threading.Thread, logging.Handler):
 
     if self.log_file:
       try:
-        self.log_file.write(event.get_display_message(True) + '\n')
+        self.log_file.write(event.get_display_message() + '\n')
         self.log_file.flush()
       except IOError as exc:
         log.error('Unable to write to log file: %s' % exc.strerror)
@@ -687,7 +682,7 @@ class LogPanel(panel.Panel, threading.Thread, logging.Handler):
         is_visible = not self.regex_filter or self.regex_filter.search(entry.get_display_message())
 
         if is_visible:
-          snapshot_file.write(entry.get_display_message(True) + '\n')
+          snapshot_file.write(entry.get_display_message() + '\n')
 
       self.vals_lock.release()
     except Exception as exc:





More information about the tor-commits mailing list