Refactor logging setup across multiple modules to use loguru with consistent configuration

- Updated logging initialization in MessageCalendar, admin_edit_prof, elsa_main, graph, iconLine, searchPage, and richtext modules to use loguru.
- Changed log rotation and retention settings for log files to improve log management.
- Replaced logger.debug/info calls with log.debug/info for consistency.
- Fixed a typo in the searchPage UI and updated related references in the UI files.
- Removed unused imports and cleaned up code for better readability.
This commit is contained in:
2025-05-13 15:49:52 +02:00
parent 4a3a95623a
commit f7c499ea6e
32 changed files with 412 additions and 491 deletions

View File

@@ -8,21 +8,14 @@ from src import Icon, settings as config
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
from .mailTemplate import MailTemplateDialog
import loguru
import sys
from loguru import logger as log
logger = log
logger.remove()
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
log.add(
"logs/mail.log",
rotation="1 day",
compression="zip",
enqueue=True,
)
log = loguru.logger
log.remove()
log.add(sys.stdout)
log.add("logs/application.log", rotation="1 MB", retention="10 days")
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
logger.add(sys.stdout)
empty_signature = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
@@ -60,7 +53,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
super().__init__(parent)
self.setupUi(self)
logger.info("Setting up mail dialog")
log.info("Setting up mail dialog")
self.appid = app_id
self.appname = app_name
self.subject = app_subject
@@ -92,7 +85,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
self.btn_okay.clicked.connect(self.createAndSendMail)
def open_new_template(self):
logger.info("Opening new template dialog")
log.info("Opening new template dialog")
# TODO: implement new mail template dialog
dialog = MailTemplateDialog()
dialog.updateSignal.connect(self.load_mail_templates)
@@ -111,9 +104,9 @@ Tel.: 0761/682-778 | 07617682-545"""
def load_mail_templates(self):
# print("loading mail templates")
logger.info("Loading mail templates")
log.info("Loading mail templates")
mail_templates = os.listdir("mail_vorlagen")
logger.info(f"Mail templates: {mail_templates}")
log.info(f"Mail templates: {mail_templates}")
self.comboBox.clear()
for template in mail_templates:
self.comboBox.addItem(template)
@@ -132,10 +125,10 @@ Tel.: 0761/682-778 | 07617682-545"""
return f"Guten Tag {name},"
def set_mail(self):
logger.info("Setting mail")
log.info("Setting mail")
email_template = self.comboBox.currentText()
if email_template == "":
logger.debug("No mail template selected")
log.debug("No mail template selected")
return
with open(f"mail_vorlagen/{email_template}", "r", encoding="utf-8") as f:
mail_template = f.read()
@@ -160,7 +153,7 @@ Tel.: 0761/682-778 | 07617682-545"""
self.mail_body.setHtml(mail_html)
def createAndSendMail(self):
logger.info("Sending mail")
log.info("Sending mail")
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@@ -197,7 +190,7 @@ Tel.: 0761/682-778 | 07617682-545"""
# print("Mail sent")
# end active process
server.quit()
logger.info("Mail sent, closing connection to server and dialog")
log.info("Mail sent, closing connection to server and dialog")
# close the dialog
self.accept()