Files
alro65 0dbc2a4518 v0.1-sprint0: Esqueleto completo AR-ShipDesign
- Estructura completa de carpetas (236 módulos stub + implementados)
- pyproject.toml, requirements, .gitignore, LICENSE (propietario)
- core/project.py: serialización .arsd (ZIP con JSON)
- core/units.py: conversiones SI <-> imperial completas
- ui/main_window.py: layout DELFTship-style con todos los paneles
  - Árbol de proyecto (dock izquierda)
  - Tabs de módulos (centro)
  - Panel de propiedades (dock derecha)
  - Panel hidrostáticos en vivo (inferior, fijo)
- ui/i18n: español e inglés
- ui/themes: tema claro y oscuro
- utils/logger.py, settings.py, validation.py
- data/liquids.json: 15 líquidos navales
- data/stability_criteria.json: IMO IS Code 2008, A.749(18), USCG
- tests/test_startup.py: 12 tests, todos PASSED
- Módulo scantling/ ISO 12215 (stubs Sprint 2.5)
- Módulo fabrication/molds/ para moldes FRP (stubs Sprint 13B)
- Módulo fabrication/ para CNC plasma/router/laser (stubs Sprint 13)
2026-05-26 22:10:18 -04:00

68 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Configuración de logging para AR-ShipDesign.
Logs rotativos en %APPDATA%/ARShipDesign/logs/
"""
import logging
import os
from logging.handlers import RotatingFileHandler
from pathlib import Path
def get_log_dir() -> Path:
"""Retorna el directorio de logs en %APPDATA%."""
appdata = os.environ.get("APPDATA", Path.home() / "AppData" / "Roaming")
log_dir = Path(appdata) / "ARShipDesign" / "logs"
log_dir.mkdir(parents=True, exist_ok=True)
return log_dir
def setup_logging(level: str = "INFO") -> logging.Logger:
"""
Configura el sistema de logging de la aplicación.
Parameters
----------
level : str
Nivel de logging: DEBUG, INFO, WARNING, ERROR
Returns
-------
logging.Logger
Logger raíz de la aplicación.
"""
numeric_level = getattr(logging, level.upper(), logging.INFO)
log_file = get_log_dir() / "arshipdesign.log"
formatter = logging.Formatter(
fmt="%(asctime)s [%(levelname)-8s] %(name)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# Handler de archivo rotativo (5 MB × 3 archivos)
file_handler = RotatingFileHandler(
log_file, maxBytes=5 * 1024 * 1024, backupCount=3, encoding="utf-8"
)
file_handler.setFormatter(formatter)
file_handler.setLevel(numeric_level)
# Handler de consola
console_handler = logging.StreamHandler()
console_handler.setFormatter(formatter)
console_handler.setLevel(numeric_level)
root_logger = logging.getLogger("arshipdesign")
root_logger.setLevel(numeric_level)
root_logger.addHandler(file_handler)
root_logger.addHandler(console_handler)
root_logger.info("AR-ShipDesign logging iniciado — nivel: %s", level)
return root_logger
def get_logger(name: str) -> logging.Logger:
"""Retorna un logger hijo del logger raíz de la app."""
return logging.getLogger(f"arshipdesign.{name}")