From 1cafb4067c4a52ee7da2089a3019294e3c6a63c8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 25 Mar 2022 20:44:26 +0800 Subject: [PATCH] bugfix --- appPublic/across_nat.py | 4 ++-- appPublic/app_logger.py | 22 +++++++++++++++++++--- setup.py | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/appPublic/across_nat.py b/appPublic/across_nat.py index 8632274..4f873c5 100644 --- a/appPublic/across_nat.py +++ b/appPublic/across_nat.py @@ -40,7 +40,7 @@ class AcrossNat(object): return x['NewExternalIPAddress'] try: return get('https://api.ipify.org').text - except: + except:/Users/ymq/pydev/github/appPublic/appPublic return get('https://ipapi.co/ip/').text def upnp_check_external_port(self, eport, protocol='TCP'): @@ -69,7 +69,7 @@ class AcrossNat(object): NewProtocol=protocol, NewInternalPort=inner_port, NewInternalClient=ip, - NewEnabled=1, + NewEnabled='1', NewPortMappingDescription=desc, NewLeaseDuration=0 ) diff --git a/appPublic/app_logger.py b/appPublic/app_logger.py index 4fe59ea..8ae21d7 100644 --- a/appPublic/app_logger.py +++ b/appPublic/app_logger.py @@ -10,18 +10,34 @@ levels={ "critical":logging.CRITICAL } defaultfmt = '%(asctime)s[%(name)s][%(filename)s:%(lineno)s]%(message)s' +logfile = -1 +level = None def create_logger(name, formater=defaultfmt, levelname='info', file=None): + global logfile, level + if logfile == -1: + logfile = file ret = logging.getLogger(name) - level = levels.get(levelname, levels.get('debug')) + if level is None: + level = levels.get(levelname, levels.get('debug')) ret.setLevel(level) format = logging.Formatter(formater) file_handler = None - if file is not None: - file_handler = logging.FileHandler(file) + if logfile is not None: + file_handler = logging.FileHandler(logfile) else: file_handler = logging.StreamHandler() file_handler.setFormatter(format) ret.addHandler(file_handler) return ret + +class AppLogger: + def __init__(self): + self.logger = create_logger(self.__class__.__name__) + self.debug = self.logger.debug + self.info = self.logger.info + self.warning = self.logger.warning + self.error = self.logger.error + self.critical = self.logger.critical + self.exception = self.logger.exception diff --git a/setup.py b/setup.py index 517e07d..f64642c 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ except ImportError: # python setup.py bdist_egg generate a egg file # Release information about eway -version = "5.1.3" +version = "5.1.4" name = "appPublic" description = "appPublic" author = "yumoqing"