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:
@@ -1,23 +1,17 @@
|
||||
import pandas as pd
|
||||
from docx import Document
|
||||
from dataclasses import dataclass
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
from src.backend import Semester
|
||||
from typing import Union, Any
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/wordparser.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/application.log",
|
||||
rotation="1 day",
|
||||
compression="zip",
|
||||
enqueue=True,
|
||||
)
|
||||
import loguru
|
||||
import sys
|
||||
|
||||
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)
|
||||
|
||||
|
||||
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
@@ -218,12 +212,12 @@ def elsa_word_to_csv(path: str):
|
||||
data = [
|
||||
row for row in df.itertuples(index=False, name=None) if row != tuples[doctype]
|
||||
]
|
||||
# logger.debug(data)
|
||||
# log.debug(data)
|
||||
return tuple_to_dict(data, doctype), doctype
|
||||
|
||||
|
||||
def word_to_semap(word_path: str) -> SemapDocument:
|
||||
logger.info("Parsing Word Document {}", word_path)
|
||||
log.info("Parsing Word Document {}", word_path)
|
||||
semap = SemapDocument()
|
||||
df = word_docx_to_csv(word_path)
|
||||
apparatdata = df[0]
|
||||
@@ -258,7 +252,7 @@ def word_to_semap(word_path: str) -> SemapDocument:
|
||||
continue
|
||||
else:
|
||||
booklist.append(book)
|
||||
logger.info("Found {} books", len(booklist))
|
||||
log.info("Found {} books", len(booklist))
|
||||
semap.books = booklist
|
||||
|
||||
return semap
|
||||
|
||||
Reference in New Issue
Block a user