From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.209]) by gnuweeb.org (Postfix) with ESMTPSA id 37CFC819FC; Wed, 21 Dec 2022 01:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671586481; bh=Pr7sZ2vd0yZ0fRb9LWDythHWmId9BtNusPstg0V0tPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IyvBUPzJpxcF3Z9A9DBHGmTjqCYA7gp+gbp7g1wWGrHesIXextebKyFwGpf9e1VLC 4EodqjSscSpNTGl1JEL/l5F8zjAIdIt3zsKdINUVEjOL9vjJ7krHNnXgFCIY8U6mPm x1x30b5RgJ6GHyUE+pvX9Fw3m5RR/Cf4YV5b/ZKxMn3s/c75nsbs2qMaB1FFXQJ4dh e/+Fby11yV5A6Z1ETZF50UR6bm4gPGk9V+he9lkQ36p1zFRjyHQo5SOX+Ese2dhkYe qsDIkEPYey6WLjgeW5+36VHQgSWI/sh4s50BWL8Hxj4KCrh9lAXJW9Q64ljR3ypNEg hop4vT9onXqow== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v4 14/17] discord: Use the BotLogger() to the GWClient() Date: Wed, 21 Dec 2022 08:33:44 +0700 Message-Id: <20221221013347.1704-15-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221221013347.1704-1-kiizuha@gnuweeb.org> References: <20221221013347.1704-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Use the BotLogger() and initialized it to the GWClient() class attribute `.logger` to use it in the future use for log a message into the file. Signed-off-by: Muhammad Rizki --- daemon/dc.py | 10 ++++++++-- daemon/dscord/gnuweeb/client.py | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/dc.py b/daemon/dc.py index 5028e94..f9b57e5 100644 --- a/daemon/dc.py +++ b/daemon/dc.py @@ -11,6 +11,8 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from dscord.gnuweeb import GWClient from dscord.mailer import Listener from dscord.mailer import Mutexes +from enums.platform import Platform +from logger import BotLogger from atom import Scraper @@ -24,13 +26,17 @@ def main(): } ) + logger = BotLogger(Platform.DISCORD) + logger.init() + client = GWClient( db_conn=connector.connect( host=os.getenv("DB_HOST"), user=os.getenv("DB_USER"), password=os.getenv("DB_PASS"), database=os.getenv("DB_NAME") - ) + ), + logger=logger ) mailer = Listener( @@ -39,8 +45,8 @@ def main(): scraper=Scraper(), mutexes=Mutexes() ) - client.mailer = mailer + client.mailer = mailer client.run(os.getenv("DISCORD_TOKEN"), log_handler=None) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index 82858c5..42bd405 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -7,22 +7,24 @@ import discord from discord import Interaction from discord.ext import commands from discord import Intents -from dscord.config import ACTIVITY_NAME from typing import Union from . import filters from . import models from atom import utils from enums import Platform +from logger.log import BotLogger +from dscord.config import ACTIVITY_NAME from dscord.database import DB class GWClient(commands.Bot): - def __init__(self, db_conn) -> None: + def __init__(self, db_conn, logger: BotLogger) -> None: self.db = DB(db_conn) intents = Intents.default() intents.message_content = True self.mailer = None + self.logger = logger super().__init__( command_prefix=["$", "."], description="Just a bot for receiving lore emails.", -- Muhammad Rizki