Refactor for logs

This commit is contained in:
Dimitris Zlatanidis 2023-06-29 12:48:00 +03:00
parent 76158a472d
commit a8060a6d7b

View file

@ -32,8 +32,8 @@ class Utilities(Configs):
self.prog_version = Version()
self.installed_packages: dict[str] = dict(self.all_installed())
self.log_date = LoggingConfig.date.replace('/', '_')
self.log_time = LoggingConfig.time.replace(':', '_')
self.process_log_date = LoggingConfig.date.replace('/', '_')
self.process_log_time = LoggingConfig.time.replace(':', '_')
logging.basicConfig(filename=LoggingConfig.log_file,
filemode=LoggingConfig.filemode,
@ -151,7 +151,7 @@ class Utilities(Configs):
output = tee = ''
if filename and self.process_log:
self.header_process_log(filename)
tee: str = f'| tee -a {self.slpkg_log_path}/{filename}_{self.log_date}_{self.log_time}.log'
tee: str = f'| tee -a {self.slpkg_log_path}/{filename}_{self.process_log_date}_{self.process_log_time}.log'
try:
output = subprocess.run(f'{command} {tee}', shell=True, stderr=stderr, stdout=stdout)
except subprocess.CalledProcessError as error:
@ -167,7 +167,7 @@ class Utilities(Configs):
def header_process_log(self, filename: str) -> None:
""" Creates the build log file and the header. """
with open(f'{self.slpkg_log_path}/{filename}_{self.log_date}_{self.log_time}.log', 'w') as f:
with open(f'{self.slpkg_log_path}/{filename}_{self.process_log_date}_{self.process_log_time}.log', 'w') as f:
f.write(f'{LoggingConfig.date_time}: {filename}: Version: {self.prog_name} {self.prog_version.version}\n')
def get_file_size(self, file: Path) -> str: