Spaces:
Sleeping
Sleeping
File size: 916 Bytes
46b9a9e 0c08dee 64bcc5c 2f10b4d 0c08dee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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 |