aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_rebind.py
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-11-04 18:09:31 +0200
committerNick Mathewson <nickm@torproject.org>2018-12-01 11:18:03 -0500
commit320f5f30b35695adf1cb1254f26af3b87ec4d2a3 (patch)
tree5635fe84cbfa85bb333c8322e92d7f2b284efe31 /src/test/test_rebind.py
parente82023d2f7b75f9ff8c4bf1ddb3c4e251142d3ab (diff)
downloadtor-320f5f30b35695adf1cb1254f26af3b87ec4d2a3.tar.gz
tor-320f5f30b35695adf1cb1254f26af3b87ec4d2a3.zip
In test_rebind.py, log stuff with timestamps
Diffstat (limited to 'src/test/test_rebind.py')
-rw-r--r--src/test/test_rebind.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test_rebind.py b/src/test/test_rebind.py
index c63341a681..64eba14f05 100644
--- a/src/test/test_rebind.py
+++ b/src/test/test_rebind.py
@@ -1,6 +1,7 @@
from __future__ import print_function
import errno
+import logging
import os
import random
import socket
@@ -13,7 +14,7 @@ LOG_WAIT = 0.1
LOG_CHECK_LIMIT = LOG_TIMEOUT / LOG_WAIT
def fail(msg):
- print('FAIL')
+ logging.error('FAIL')
sys.exit(msg)
def try_connecting_to_socksport():
@@ -30,7 +31,7 @@ def wait_for_log(s):
l = l.decode('utf8')
if s in l:
return
- print('Tor logged: "{}", waiting for "{}"'.format(l.strip(), s))
+ logging.info('Tor logged: "{}", waiting for "{}"'.format(l.strip(), s))
# readline() returns a blank string when there is no output
# avoid busy-waiting
if len(s) == 0:
@@ -55,6 +56,10 @@ def pick_random_port():
return port
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s.%(msecs)03d %(message)s',
+ datefmt='%Y-%m-%d %H:%M:%S')
+
if sys.hexversion < 0x02070000:
fail("ERROR: unsupported Python version (should be >= 2.7)")
@@ -108,13 +113,13 @@ try_connecting_to_socksport()
control_socket.sendall('SIGNAL HALT\r\n'.encode('utf8'))
wait_for_log('exiting cleanly')
-print('OK')
+logging.info('OK')
try:
tor_process.terminate()
except OSError as e:
if e.errno == errno.ESRCH: # errno 3: No such process
# assume tor has already exited due to SIGNAL HALT
- print("Tor has already exited")
+ logging.warn("Tor has already exited")
else:
raise