logger.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. -----------------------------------------------------------------------------------------
  3. INTERSEL - 4 cité d'Hauteville - 75010 PARIS
  4. RCS PARIS 488 379 660 - NAF 721Z
  5. File : config/logger.py
  6. Object : Logging configuration for the MCP server
  7. -----------------------------------------------------------------------------------------
  8. Modifications :
  9. - 2026/01/16 - Damien Lugagne-Delpon - V1.0.0- Creation
  10. -----------------------------------------------------------------------------------------
  11. @copyright : Intersel 2026
  12. @author : Damien Lugagne-Delpon - damien.lugagne-delpon@livinweb.fr
  13. @version : 1.0.0 (to be updated to the current_version of the developed software if file is touched)
  14. -----------------------------------------------------------------------------------------
  15. """
  16. import logging
  17. from config.settings import LOG_LEVEL, APP_NAME
  18. def init_logger():
  19. """Initilize the logger for the MCP server."""
  20. logger = logging.getLogger(APP_NAME)
  21. if logger.hasHandlers():
  22. logger.handlers.clear()
  23. logger.setLevel(getattr(logging, LOG_LEVEL))
  24. ch = logging.StreamHandler()
  25. ch.setLevel(getattr(logging, LOG_LEVEL))
  26. formatter = logging.Formatter('[%(asctime)s] - [%(levelname)s] - %(name)s - %(message)s')
  27. ch.setFormatter(formatter)
  28. logger.addHandler(ch)
  29. return logger