logic helper functions
This commit is contained in:
17
app/logic/logger.py
Normal file
17
app/logic/logger.py
Normal 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()
|
||||
Reference in New Issue
Block a user