def log_exception(message: str = None, logger: logging = None): if logger is None: logger = logging.getLogger(__name__) if message is None: message = "An exception occurred" formatted_message = f"Component version: {MEROSS_CLOUD_VERSION}, Message: \"{message}\"" logger.exception(formatted_message)
def log_exception(message: str = None, logger: logging = None, device: AbstractMerossDevice = None): if logger is None: logger = logging.getLogger(__name__) if message is None: message = "An exception occurred" device_info = "<Unavailable>" if device is not None: device_info = f"\tName: {device.name}\n" \ f"\tUUID: {device.uuid}\n" \ f"\tType: {device.type}\n\t" \ f"HW Version: {device.hwversion}\n" \ f"\tFW Version: {device.fwversion}" formatted_message = f"Error occurred.\n" \ f"-------------------------------------\n" \ f"Component version: {MEROSS_CLOUD_VERSION}\n" \ f"Device info: \n" \ f"{device_info}\n" \ f"Error Message: \"{message}\"" logger.exception(formatted_message)