Исправил logging

sandbox1
inpos 2016-03-04 19:27:34 +03:00
parent e852a9ad58
commit 2c7952ff01
2 changed files with 10 additions and 4 deletions

View File

@ -21,6 +21,7 @@ from . import SessionStatus, FileStatus, PeerInfo, MediaType, Encryption
from util import can_bind, find_free_port, ensure_fs_encoding from util import can_bind, find_free_port, ensure_fs_encoding
import threading import threading
LOGGING = True
class Engine: class Engine:
""" """
@ -202,6 +203,7 @@ class Engine:
self.logpipe = None self.logpipe = None
# self.process = None # self.process = None
self.started = False self.started = False
self.pyrrent2http_loop = None
@staticmethod @staticmethod
def _validate_save_path(path): def _validate_save_path(path):
@ -302,9 +304,11 @@ class Engine:
def __init__(self, _log): def __init__(self, _log):
self._log = _log self._log = _log
def info(self, message): def info(self, message):
self._log('INFO: %s' % (message,)) if LOGGING:
self._log('INFO: %s' % (message,))
def error(self, message): def error(self, message):
self._log('ERROR: %s' % (message,)) if LOGGING:
self._log('ERROR: %s' % (message,))
pyrrent2http.logging = Logging(self._log) pyrrent2http.logging = Logging(self._log)
# startupinfo = None # startupinfo = None
# if self.platform.system == "windows": # if self.platform.system == "windows":
@ -485,7 +489,8 @@ class Engine:
""" """
# if self.logpipe and self.wait_on_close_timeout is None: # if self.logpipe and self.wait_on_close_timeout is None:
# self.logpipe.close() # self.logpipe.close()
if self.is_alive(): ### if self.is_alive():
if True:
self._log("Shutting down pyrrent2http...") self._log("Shutting down pyrrent2http...")
# self._request('shutdown') # self._request('shutdown')
self.pyrrent2http.shutdown() self.pyrrent2http.shutdown()

View File

@ -28,7 +28,7 @@ import io
import socket import socket
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
###################################################################################### ######################################################################################
@ -1063,6 +1063,7 @@ class Pyrrent2http(object):
if __name__ == '__main__': if __name__ == '__main__':
try: try:
import logging import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
pyrrent2http = Pyrrent2http() pyrrent2http = Pyrrent2http()
pyrrent2http.parseFlags() pyrrent2http.parseFlags()