[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [nyx/master] Replace deprecated LogBuffer
commit 3f9950051e67c1ef38fd7799a3646308082d58b1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Thu Oct 15 15:45:28 2020 -0700
Replace deprecated LogBuffer
Stem 2.x drops deprecated classes. As a result we error with...
Traceback (most recent call last):
File "./run_nyx", line 7, in <module>
import nyx
File "/home/atagar/Desktop/nyx/nyx/__init__.py", line 779, in <module>
import nyx.panel.log
File "/home/atagar/Desktop/nyx/nyx/panel/log.py", line 69, in <module>
NYX_LOGGER = log.LogBuffer(log.Runlevel.DEBUG, yield_records = True)
AttributeError: module 'stem.util.log' has no attribute 'LogBuffer'
This was removed in stem commit 76b6b49. Fortunately it's a simple class to
replace.
---
nyx/panel/log.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 76dd20c..030be38 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -9,6 +9,9 @@ regular expressions.
import functools
import os
+import logging
+import logging.handlers
+import queue
import time
import stem.response.events
@@ -66,7 +69,10 @@ CONTENT_HEIGHT_REDRAW_THRESHOLD = 3
# to make our LogPanel when curses initializes.
stem_logger = log.get_logger()
-NYX_LOGGER = log.LogBuffer(log.Runlevel.DEBUG, yield_records = True)
+NYX_LOG_BUFFER = queue.Queue()
+
+NYX_LOGGER = logging.handlers.QueueHandler(NYX_LOG_BUFFER)
+NYX_LOGGER.setLevel(logging.DEBUG)
stem_logger.addHandler(NYX_LOGGER)
@@ -123,8 +129,8 @@ class LogPanel(nyx.panel.DaemonPanel):
# merge NYX_LOGGER into us, and listen for its future events
- for event in NYX_LOGGER:
- self._register_nyx_event(event)
+ while not NYX_LOG_BUFFER.empty():
+ self._register_nyx_event(NYX_LOG_BUFFER.get_nowait())
NYX_LOGGER.emit = self._register_nyx_event
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits