logic helper functions

This commit is contained in:
2025-06-25 20:48:20 +01:00
parent afa01fbba5
commit 9790baedec
2 changed files with 166 additions and 0 deletions

17
app/logic/logger.py Normal file
View File

@@ -0,0 +1,17 @@
from datetime import datetime
class Logger:
def __init__(self, log_widget=None, log_file_path="nginx_deploy_gui.log"):
self.log_widget = log_widget
self.log_file = open(log_file_path, "a")
def log(self, message):
timestamp = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
full_message = f"{timestamp} {message}\n"
if self.log_widget:
self.log_widget.append(full_message)
self.log_file.write(full_message)
self.log_file.flush()
def close(self):
self.log_file.close()