changed visiblity log methods in publisher
This commit is contained in:
parent
a45c2c19ec
commit
df837b17b6
|
@ -68,21 +68,25 @@ class AbstractPublisher(ABC):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def log_debug(self, msg, *args, **kwargs):
|
def _log_debug(self, msg, *args, **kwargs):
|
||||||
self.__log(logging.DEBUG, msg, *args, **kwargs)
|
self.__log(logging.DEBUG, msg, *args, **kwargs)
|
||||||
|
|
||||||
def log_info(self, msg, *args, **kwargs):
|
def _log_info(self, msg, *args, **kwargs):
|
||||||
self.__log(logging.INFO, msg, *args, **kwargs)
|
self.__log(logging.INFO, msg, *args, **kwargs)
|
||||||
|
|
||||||
def log_warning(self, msg, *args, **kwargs):
|
def _log_warning(self, msg, *args, **kwargs):
|
||||||
self.__log(logging.WARNING, msg, *args, **kwargs)
|
self.__log(logging.WARNING, msg, *args, **kwargs)
|
||||||
|
|
||||||
def log_error(self, msg, *args, **kwargs):
|
def _log_error(self, msg, *args, **kwargs):
|
||||||
self.__log(logging.ERROR, msg, *args, **kwargs)
|
self.__log(logging.ERROR, msg, *args, **kwargs)
|
||||||
|
|
||||||
def log_critical(self, msg, *args, **kwargs):
|
def _log_critical(self, msg, *args, **kwargs):
|
||||||
self.__log(logging.CRITICAL, msg, *args, **kwargs)
|
self.__log(logging.CRITICAL, msg, *args, **kwargs)
|
||||||
|
|
||||||
def __log(self, level, msg, *args, **kwargs):
|
def __log(self, level, msg, *args, **kwargs):
|
||||||
method = inspect.currentframe().f_back.f_back.f_code.co_name
|
method = inspect.currentframe().f_back.f_back.f_code.co_name
|
||||||
logger.log(level, f"{self}.{method}(): {msg}", *args, **kwargs)
|
logger.log(level, f"{self}.{method}(): {msg}", *args, **kwargs)
|
||||||
|
|
||||||
|
def _log_error_and_raise(self, message):
|
||||||
|
self._log_error(message)
|
||||||
|
raise ValueError(message)
|
||||||
|
|
|
@ -15,10 +15,6 @@ class TelegramPublisher(AbstractPublisher):
|
||||||
)
|
)
|
||||||
return self._validate_response(res)
|
return self._validate_response(res)
|
||||||
|
|
||||||
def _log_error_and_raise(self, message):
|
|
||||||
self.log_error(message)
|
|
||||||
raise ValueError(message)
|
|
||||||
|
|
||||||
def validate_credentials(self) -> bool:
|
def validate_credentials(self) -> bool:
|
||||||
chat_id = self.credentials.get("chat_id")
|
chat_id = self.credentials.get("chat_id")
|
||||||
token = self.credentials.get("token")
|
token = self.credentials.get("token")
|
||||||
|
@ -45,7 +41,7 @@ class TelegramPublisher(AbstractPublisher):
|
||||||
try:
|
try:
|
||||||
data = res.json()
|
data = res.json()
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.log_error("Server returned invalid json data")
|
self._log_error("Server returned invalid json data")
|
||||||
raise ValueError from e
|
raise ValueError from e
|
||||||
|
|
||||||
if not data.get("ok"):
|
if not data.get("ok"):
|
||||||
|
|
Loading…
Reference in New Issue