logging_mixin.py
1 import logging 2 3 4 class LoggingMixin: 5 def log(self, level, msg, *args, **kwargs): 6 msg = f"{self.session_id}: {msg}" 7 logging.log(level, msg, *args, **kwargs) 8 9 def log_debug(self, message, *args, **kwargs): 10 self.log(logging.DEBUG, message, *args, **kwargs) 11 12 def log_error(self, message, *args, **kwargs): 13 self.log(logging.ERROR, message, *args, **kwargs) 14 15 def log_critical(self, message, *args, **kwargs): 16 self.log(logging.CRITICAL, message, *args, **kwargs) 17 18 def log_info(self, message, *args, **kwargs): 19 self.log(logging.INFO, message, *args, **kwargs)