Implemented new logging functions, refactored to suit.

This commit is contained in:
th3r00t
2020-08-25 13:59:06 -04:00
parent 59719c19f2
commit f2729e05db
9 changed files with 59 additions and 69 deletions

View File

@@ -1,5 +1,6 @@
import json
import pathlib
from loguru import logger
@@ -8,49 +9,49 @@ class Config:
Main System Configuration
"""
_fp = "config.json"
def __init__(self, root):
"""
Initialize main configuration options
"""
_cp = pathlib.Path.joinpath(root, self._fp)
_data = self.open_file(_cp)
self._fp = "config.json"
self._cp = pathlib.Path.joinpath(root, self._fp)
self._data = self.open_file()
self.root = root
self.logger = self.get_logger()
self.book_path = _data["BOOKPATH"]
self.TITLE = _data["TITLE"]
self.VERSION = _data["VERSION"]
self.book_path = self._data["BOOKPATH"]
self.TITLE = self._data["TITLE"]
self.VERSION = self._data["VERSION"]
self.TITLE = self.TITLE + " ver " + self.VERSION
self.book_shelf = _data["BOOKSHELF"]
self.catalogue_db = _data["DATABASE"]
self.user = _data["USER"]
self.password = _data["PASSWORD"]
self.db_host = _data["DB_HOST"]
self.db_port = _data["DB_PORT"]
self.book_shelf = self._data["BOOKSHELF"]
self.catalogue_db = self._data["DATABASE"]
self.user = self._data["USER"]
self.password = self._data["PASSWORD"]
self.db_host = self._data["DB_HOST"]
self.db_port = self._data["DB_PORT"]
self.file_array = [
self.book_shelf,
]
self.auto_scan = True
self.allowed_hosts = _data["ALLOWED_HOSTS"]
self.db_user = _data["USER"]
self.db_pass = _data["PASSWORD"]
self.SECRET = _data["SECRET"]
self.allowed_hosts = self._data["ALLOWED_HOSTS"]
self.db_user = self._data["USER"]
self.db_pass = self._data["PASSWORD"]
self.SECRET = self._data["SECRET"]
def get_logger(self):
_logger = logger
_logger.add(pathlib.PurePath(self.root, 'data','pyShelf_{time}.log'), rotation="10 MB", loop=None)
_logger.add(pathlib.PurePath(self.root, 'data','pyShelf_{time}.log'),
rotation="10 MB", enqueue=True, colorize=True)
return _logger
@staticmethod
def open_file(_cp):
def open_file(self):
"""
Opens config.json and reads in configuration options
"""
with open(str(_cp), "r") as read_file:
with open(str(self._cp), "r") as read_file:
data = json.load(read_file)
return data
def django_secret(self, _data):
def django_secret(self):
pass