From 2c7952ff01f147fcc7e1138feef183dd29e2b8e2 Mon Sep 17 00:00:00 2001 From: inpos Date: Fri, 4 Mar 2016 19:27:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pyrrent2http/engine.py | 11 ++++++++--- lib/pyrrent2http/pyrrent2http.py | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pyrrent2http/engine.py b/lib/pyrrent2http/engine.py index a0c109d..5e104ad 100644 --- a/lib/pyrrent2http/engine.py +++ b/lib/pyrrent2http/engine.py @@ -21,6 +21,7 @@ from . import SessionStatus, FileStatus, PeerInfo, MediaType, Encryption from util import can_bind, find_free_port, ensure_fs_encoding import threading +LOGGING = True class Engine: """ @@ -202,6 +203,7 @@ class Engine: self.logpipe = None # self.process = None self.started = False + self.pyrrent2http_loop = None @staticmethod def _validate_save_path(path): @@ -302,9 +304,11 @@ class Engine: def __init__(self, _log): self._log = _log def info(self, message): - self._log('INFO: %s' % (message,)) + if LOGGING: + self._log('INFO: %s' % (message,)) def error(self, message): - self._log('ERROR: %s' % (message,)) + if LOGGING: + self._log('ERROR: %s' % (message,)) pyrrent2http.logging = Logging(self._log) # startupinfo = None # if self.platform.system == "windows": @@ -485,7 +489,8 @@ class Engine: """ # if self.logpipe and self.wait_on_close_timeout is None: # self.logpipe.close() - if self.is_alive(): +### if self.is_alive(): + if True: self._log("Shutting down pyrrent2http...") # self._request('shutdown') self.pyrrent2http.shutdown() diff --git a/lib/pyrrent2http/pyrrent2http.py b/lib/pyrrent2http/pyrrent2http.py index 5fd586c..01fd0d9 100644 --- a/lib/pyrrent2http/pyrrent2http.py +++ b/lib/pyrrent2http/pyrrent2http.py @@ -28,7 +28,7 @@ import io import socket -logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) + ###################################################################################### @@ -1063,6 +1063,7 @@ class Pyrrent2http(object): if __name__ == '__main__': try: import logging + logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG) pyrrent2http = Pyrrent2http() pyrrent2http.parseFlags()