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

@@ -9,18 +9,14 @@ from src.backend.database import Database
from src.logic.webrequest import BibTextTransformer, WebRequest
# from src.transformers import RDS_AVAIL_DATA
from loguru import logger as log
import loguru
import sys
logger = log
logger.remove()
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
log.add(
"logs/availthread.log",
)
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)
class AvailChecker(QThread):
@@ -33,8 +29,8 @@ class AvailChecker(QThread):
if links is None:
links = []
super().__init__(parent)
logger.info("Starting worker thread")
logger.info(
log.info("Starting worker thread")
log.info(
"Checking availability for "
+ str(links)
+ " with appnumber "
@@ -44,7 +40,7 @@ class AvailChecker(QThread):
self.links = links
self.appnumber = appnumber
self.books = books
logger.info(
log.info(
f"Started worker with appnumber: {self.appnumber} and links: {self.links} and {len(self.books)} books..."
)
time.sleep(2)
@@ -54,7 +50,7 @@ class AvailChecker(QThread):
state = 0
count = 0
for link in self.links:
logger.info("Processing entry: " + str(link))
log.info("Processing entry: " + str(link))
data = WebRequest().set_apparat(self.appnumber).get_ppn(link).get_data()
transformer = BibTextTransformer("RDS")
rds = transformer.get_data(data).return_data("rds_availability")
@@ -71,14 +67,14 @@ class AvailChecker(QThread):
if book["bookdata"].signature == link:
book_id = book["id"]
break
logger.info(f"State of {link}: " + str(state))
log.info(f"State of {link}: " + str(state))
# print("Updating availability of " + str(book_id) + " to " + str(state))
self.db.setAvailability(book_id, state)
count += 1
self.updateProgress.emit(count, len(self.links))
self.updateSignal.emit(item.callnumber, state)
logger.info("Worker thread finished")
log.info("Worker thread finished")
# teminate thread
self.quit()