app/package/common_pkg/service_pkg/logger.py
def _send_webhook(self,
                      msg: str,
                      is_error=True):
        """Function to push a webhook to slack channel

            Args:
                msg: log message
                is_error: flag to signal if message is the error message
        """
        if self.webhook_url is None:
            return

        color = "#ff003a"
        level = "ERROR"
        if not is_error:
            color = "#36a64f"
            level = "INFO"

        body = {
            "attachments": [
                {
                    "color": color,
                    "author_name": self.logger_name,
                    "title": level,
                    "text": msg,
                    "ts": int(time.time())
                }
            ]
        }

        try:
            res = requests.post(url=self.webhook_url,
                                headers={"Content-type": "application/json"},
                                json=body)
            if res.status_code > 200:
                self.logs.error("Cannot push webhook using provided URL")
                self.webhook_url = None
        except Exception as ex:
            self.logs.error("Cannot push webhook using provided URL")
            self.webhook_url = None
Function to push a webhook to slack channel

            Args:
                msg: log message
                is_error: flag to signal if message is the error message
        
Function to push a webhook to slack channel
Function to push a webhook to slack channel
def _send_webhook(self,
                      msg: str,
                      is_error=True):
        if self.webhook_url is None:
            return
        color = "#ff003a"
        level = "ERROR"
        if not is_error:
            color = "#36a64f"
            level = "INFO"
        body = {
            "attachments": [
                {
                    "color": color,
                    "author_name": self.logger_name,
                    "title": level,
                    "text": msg,
                    "ts": int(time.time())
                }
            ]
        }
        try:
            res = requests.post(url=self.webhook_url,
                                headers={"Content-type": "application/json"},
                                json=body)
            if res.status_code > 200:
                self.logs.error("Cannot push webhook using provided URL")
                self.webhook_url = None
        except Exception as ex:
            self.logs.error("Cannot push webhook using provided URL")
            self.webhook_url = None
def _send_webhook ( self , msg : str , is_error = True ) : if self . webhook_url is None : return color = "#ff003a" level = "ERROR" if not is_error : color = "#36a64f" level = "INFO" body = { "attachments" : [ { "color" : color , "author_name" : self . logger_name , "title" : level , "text" : msg , "ts" : int ( time . time ( ) ) } ] } try : res = requests . post ( url = self . webhook_url , headers = { "Content-type" : "application/json" } , json = body ) if res . status_code > 200 : self . logs . error ( "Cannot push webhook using provided URL" ) self . webhook_url = None except Exception as ex : self . logs . error ( "Cannot push webhook using provided URL" ) self . webhook_url = None
Function to push a webhook to slack channel
Function to push a webhook to slack channel
"""Function to push a webhook to slack channel

            Args:
                msg: log message
                is_error: flag to signal if message is the error message
        """
self
msg
str
None
is_error
flag to signal if message is the error message
flag to signal if message is the error message