Spaces:
Sleeping
Sleeping
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 |