Fix issues in naming and few other things

This commit is contained in:
ahmadbilalkhalid 2019-12-14 20:23:31 +05:00
commit 71279a968f
21 changed files with 274 additions and 281 deletions

View file

@ -6,21 +6,7 @@ import json
from ipaddress import ip_address
from os.path import join as join_path
def create_package_loggers(packages, base_path, mode="a"):
loggers = {}
for pkg in packages:
logger = logging.getLogger(pkg)
logger_handler = logging.FileHandler(
join_path(base_path, "{}.txt".format(pkg)),
mode=mode
)
logger.setLevel(logging.DEBUG)
logger_handler.setFormatter(logging.Formatter(fmt="%(asctime)s: %(levelname)s - %(message)s",
datefmt="%d-%b-%y %H:%M:%S"))
logger.addHandler(logger_handler)
loggers[pkg] = logger
from . import logger
# TODO: Should be removed as soon as migration
@ -35,7 +21,7 @@ def get_ipv4_address():
except socket.timeout:
address = "127.0.0.1"
except Exception as e:
logging.getLogger().exception(e)
logger.exception(e)
address = "127.0.0.1"
else:
address = s.getsockname()[0]
@ -49,6 +35,6 @@ def get_ipv6_address():
content = json.loads(r.content.decode("utf-8"))
ip = ip_address(content["ip"]).exploded
except Exception as e:
logging.exception(e)
logger.exception(e)
else:
return ip