Logging System Design
jhj
2026년 07월 19일
Lumipet Re-ID Logging System Design Spec
Date: 2026-07-19
Status: Approved
Scope: Replace ad-hoc print() statements with a structured, Ultralytics-style singleton LOGGER.
1. Overview
The goal is to transition lumipet-reid from raw print() statements to a unified, configurable logging system. The design is inspired by Ultralytics (ultralytics.utils.LOGGER) to provide clean terminal coloring, configurable verbosity/log levels, optional file logging, and structured model loading diagnostics.
2. Architecture & Components
2.1 Logger Module (reid/utils/logger.py)
- Singleton Logger (
LOGGER): Globallogging.Loggerinstance named"lumipet-reid". ColoredFormatter: Customlogging.Formatterproviding ANSI color coding for terminal output:DEBUG: Gray/Cyan prefix (DEBUG)INFO: Standard clear text / Green accent ([ReID] INFO)WARNING: Yellow text with icon (WARNING ⚠️)ERROR: Red bold text with icon (ERROR ❌)
set_logging(name="lumipet-reid", verbose="INFO", log_file=None):- Dynamically updates the log level and handlers on
LOGGER. - Supports optional file logging (
FileHandler) with non-colored ISO timestamps (YYYY-MM-DD HH:MM:SS).
- Dynamically updates the log level and handlers on
2.2 Log Level Hierarchy & verbose Configuration
Standard logging hierarchy applies (a level outputs all messages at or above its priority):
DEBUG(10) ➔ OutputsDEBUG,INFO,WARNING,ERROR,CRITICALINFO(20) ➔ OutputsINFO,WARNING,ERROR,CRITICALWARNING(30) ➔ OutputsWARNING,ERROR,CRITICALERROR(40) ➔ OutputsERROR,CRITICAL
verbose mapping logic in set_logging():
Trueor"INFO"(default) ➔logging.INFOFalseor"WARNING"➔logging.WARNING(Quiet mode)"DEBUG"➔logging.DEBUG(Detailed debugging)"ERROR"➔logging.ERROR(Errors only)
3. Configuration Updates (config.yaml & reid/cfg/default.yaml)
Add the following fields to both configuration files under # Device & Run Settings:
# Logging Settings
verbose: "INFO" # Logging level: "INFO", "DEBUG", "WARNING", "ERROR", or boolean (True/False)
log_file: None # Optional file path to save logs (e.g. "logs/reid.log")
4. Model Weight Loading Logging Specification
When model weights are loaded (PyTorch checkpoints, ONNX, or TensorRT), structured logs will be emitted:
LOGGER.info(Summary Level):- Format:
[ReID] INFO 🚀 <Component> loaded: '<ModelName/Weights>' (Device: <device>, Precision: <precision>, Format: <format>) - Examples:
[ReID] INFO 🚀 Extractor loaded: 'wildlife_tools_step2_hybrid_08.pth' (Device: cuda, Precision: fp16, Format: PyTorch)[ReID] INFO ⚡ Extractor ONNX loaded: 'wildlife_tools_step2_hybrid_08.onnx' (Provider: CUDAExecutionProvider)
- Format:
LOGGER.debug(Detailed Level):- Detailed state dict information (number of loaded keys, projection layers, missing/unexpected keys count).
5. Migration Targets (print -> LOGGER)
The following files will be refactored to replace print() with appropriate LOGGER calls:
reid/cli.py: CLI summary, delete/migrate status, error messages.reid/engine/predictor.py&trainer.py: Profiler summary, weights saving notifications.reid/models/extractor/predict.py: ONNX export and simplification progress.reid/models/extractor/wildlife/model.py&mega_descriptor/model.py: Weight loading logs.reid/models/extractor/val.py: Validation gallery building and accuracy reporting.reid/models/extractor/embedding.py: Database mismatch warnings.reid/utils/checks.py: CUDA fallback warning.reid/data/loader.py: Dataset missing warning.
C
Contents
