Skip to content

Commit

Permalink
Change type of logging queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius committed Oct 16, 2023
1 parent 271e23d commit 55ff9c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/utils/custom_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import asyncio
import logging
import queue
from logging.handlers import QueueHandler, QueueListener, RotatingFileHandler
from pathlib import Path
from typing import TYPE_CHECKING, Any, TypeAlias, TypeVar
Expand Down Expand Up @@ -128,11 +129,11 @@ def __enter__(self) -> Self:
self.log.addHandler(stream_handler)

# Add a queue handler and listener.
queue: asyncio.Queue[logging.LogRecord] = asyncio.Queue()
queue_handler = QueueHandler(queue)
log_queue: queue.Queue[logging.LogRecord] = queue.Queue()
queue_handler = QueueHandler(log_queue)
webhook = discord.Webhook.from_url(core.CONFIG.discord.logging_webhook, session=self.session)
webhook_handler = DiscordWebhookHandler(webhook)
self.queue_listener = QueueListener(queue, webhook_handler)
self.queue_listener = QueueListener(log_queue, webhook_handler)

self.log.addHandler(queue_handler)
self.queue_listener.start()
Expand Down

0 comments on commit 55ff9c7

Please sign in to comment.