- Implement main application entry point in duck-ocr.py - Create logging configuration in logging_config.py - Add video streaming functionality in camera.py - Introduce main window UI in main_window.py - Include SVG assets for UI buttons and icons - Update .gitignore to exclude log files - Add placeholder .gitkeep files for empty directories
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
# logging_config.py
|
|
|
|
import logging
|
|
import logging.handlers
|
|
from pathlib import Path
|
|
|
|
|
|
LOG_DIR = Path("logs")
|
|
LOG_DIR.mkdir(exist_ok=True)
|
|
|
|
LOG_FILE = LOG_DIR / "app.log"
|
|
|
|
|
|
def setup_logging():
|
|
formatter = logging.Formatter(
|
|
fmt="%(asctime)s | %(levelname)-8s | %(threadName)s | %(name)s | %(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
)
|
|
|
|
# logger główny
|
|
logger = logging.getLogger()
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
# zabezpieczenie przed dodaniem handlerów drugi raz
|
|
if logger.handlers:
|
|
return
|
|
|
|
# console
|
|
console_handler = logging.StreamHandler()
|
|
console_handler.setLevel(logging.INFO)
|
|
console_handler.setFormatter(formatter)
|
|
|
|
# plik
|
|
file_handler = logging.handlers.RotatingFileHandler(
|
|
LOG_FILE,
|
|
maxBytes=5_000_000,
|
|
backupCount=3,
|
|
encoding="utf-8",
|
|
)
|
|
|
|
file_handler.setLevel(logging.DEBUG)
|
|
file_handler.setFormatter(formatter)
|
|
|
|
logger.addHandler(console_handler)
|
|
logger.addHandler(file_handler) |