Исправил logging
This commit is contained in:
		
							parent
							
								
									e852a9ad58
								
							
						
					
					
						commit
						2c7952ff01
					
				@ -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,8 +304,10 @@ class Engine:
 | 
			
		||||
            def __init__(self, _log):
 | 
			
		||||
                self._log = _log
 | 
			
		||||
            def info(self, message):
 | 
			
		||||
                if LOGGING:
 | 
			
		||||
                    self._log('INFO: %s' % (message,))
 | 
			
		||||
            def error(self, message):
 | 
			
		||||
                if LOGGING:
 | 
			
		||||
                    self._log('ERROR: %s' % (message,))
 | 
			
		||||
        pyrrent2http.logging = Logging(self._log)
 | 
			
		||||
#        startupinfo = None
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user