from discord_logger import DiscordLogger

webhook_url = "your discord webhook url"
options = {
    "application_name": "My Server",
    "service_name": "Backend API",
    "service_icon_url": "your icon url",
    "service_environment": "Production",
    "default_level": "info",
    "display_hostname": False,
}

logger = DiscordLogger(webhook_url=webhook_url, **options)

logger.construct(title="Health Check",
                 description="All services are running normally!")
response = logger.send()
Пример #2
0
from discord_logger import DiscordLogger

webhook_url = "your discord webhook url"
options = {
    "application_name": "My Server",
    "service_name": "Backend API",
    "service_icon_url": "your icon url",
    "service_environment": "Production",
    "default_level": "info",
}

logger = DiscordLogger(webhook_url=webhook_url, **options)

logger.construct(
    title="Health Check",
    description="Issue in establishing DB connections!",
    error="Traceback (most recent call last):\n ValueError: Database connect accepts only string as a parameter!",
    metadata={"module": "DBConnector", "host": 123.332},
)
response = logger.send()
        "Traceback (most recent call last):\n" +
        "".join(traceback.format_list(traceback.extract_tb(e.__traceback__))) +
        type(e).__name__ + ": " + str(e))
    return tb


webhook_url = "your discord webhook url"
options = {
    "application_name": "My Server",
    "service_name": "Backend API",
    "service_icon_url": "your icon url",
    "service_environment": "Production",
    "default_level": "info",
}

err = KeyError("`email` field cannot be None")

logger = DiscordLogger(webhook_url=webhook_url, **options)

logger.construct(
    title="Runtime Exception",
    description=err.__str__(),
    error=get_traceback(err),
    metadata={
        "email": None,
        "module": "auth",
        "method": "POST"
    },
)
response = logger.send()
Пример #4
0
from discord_logger import DiscordLogger

webhook_url = "your discord webhook url"
options = {
    "application_name": "My Server",
    "service_name": "Backend API",
    "service_icon_url": "your icon url",
    "service_environment": "Production",
    "default_level": "info",
}

logger = DiscordLogger(webhook_url=webhook_url, **options)

logger.construct(
    title="Celery Task Manager",
    description="Successfully completed training job for model v1.3.3!",
    level="success",
    metadata={
        "Metrics": {
            "Accuracy": 78.9,
            "Inference time": "0.8 sec",
            "Model size": "32 MB",
        },
        "Deployment status": "progress",
    },
)
response = logger.send()
Пример #5
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.logger = DiscordLogger(webhook_url=cfg["logger_hook"], **cfg["logger_ops"])
     self.logger.construct(title="Startup", description="Robo Vco is starting up.")
     self.logger.send()
Пример #6
0
class Bot(commands.Bot):
    """A subclassed commands.Bot"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.logger = DiscordLogger(webhook_url=cfg["logger_hook"], **cfg["logger_ops"])
        self.logger.construct(title="Startup", description="Robo Vco is starting up.")
        self.logger.send()

    def load_extensions(self, cogs: list):
        """Loads a list of cogs"""
        loading_data = {
            "success":0,
            "failure":0
        }
        for cog in cogs:
            try:
                super().load_extension(cog)
                loading_data["success"] += 1
            except Exception as e:
                loading_data["failure"] += 1
                self.logger.construct(title="Startup", description=f"Cog `{cog}` failed to load.", error=e)
                self.logger.send()
        self.logger.construct(title="Startup", description="Cog loading has finished.", metadata=loading_data)
        self.logger.send()

    async def on_error(self, event: str, *args, **kwargs):
        self.logger.construct(title="Runtime Error", error=event, metadata=kwargs)
        self.logger.send()