TruesAutoBlacklister / classes.py
Ufoptg's picture
Update classes.py
64bcc5c verified
raw
history blame
No virus
916 Bytes
import aiologger
from aiologger.handlers.files import AsyncFileHandler
logger = aiologger.Logger.with_default_handlers(
name="TruesAutoBlacklister",
level=aiologger.levels.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
class CustHand(logging.Handler):
def __init__(self, client, chat_id):
super().__init__()
self.client = client
self.chat_id = chat_id
async def emit(self, record):
log_entry = self.format(record)
await self.client.send_message(chat_id=self.chat_id, text=log_entry)
class CustHand2(AsyncFileHandler):
def __init__(self, client, chat_id, *args, **kwargs):
super().__init__(*args, **kwargs)
self.client = client
self.chat_id = chat_id
async def emit(self, record):
log_entry = self.format(record)
await self.client.send_message(chat_id=self.chat_id, text=log_entry