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.126.198]) by gnuweeb.org (Postfix) with ESMTPSA id 980C9804D1; Wed, 9 Nov 2022 02:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667962240; bh=rmnlDun6QZZazGaBAcjX+RkXn1KN96TdTo8vgnVRgYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EhBzQk3YUxQZZu+n+hZc7C6c/e+QxLs3Qc+0b5D6hjCjTVzwxRh6YdelGNzFMbS9j yZivutOxHR07er2mapFEWH/lRl8yx8mciOlDHrQO/8KXOT7RDYVh9NuYAhA+cLgriI Z2lfReiNagjYqgEgujq1O/q1W01Yl3V5tv0UFjHAdNzvdprPr9xuzqz8CU4HtP0LvG C3tgWoo8tiO5pGtfWcgh9psJIKZmHSYQ8eTS9NmF/i35BC2UXi0JTTIEbZxWfrpSA9 gMXP1oln+v4gz0XVu1lDju4i1djPfThX65M/lIHXbmx90tpkWQuSus2LZfHX60CQAH ftTqB7jTEDZfg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 09/17] telegram: Use the created BotLogger() class Date: Wed, 9 Nov 2022 09:49:54 +0700 Message-Id: <20221109025002.258-10-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221109025002.258-1-kiizuha@gnuweeb.org> References: <20221109025002.258-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Use the BotLogger() class for the Telegram DaemonClient() class. This class is to make a log message to a file within the DaemonClient() class of the `.logger` attribute which is initialized from the BotLogger() class. Signed-off-by: Muhammad Rizki --- daemon/telegram/packages/client.py | 6 +++++- daemon/tg.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/daemon/telegram/packages/client.py b/daemon/telegram/packages/client.py index c971ea1..eb282eb 100644 --- a/daemon/telegram/packages/client.py +++ b/daemon/telegram/packages/client.py @@ -10,16 +10,20 @@ from typing import Union from email.message import Message from atom import utils from enums import Platform +from logger import BotLogger from telegram.database import DB from .decorator import handle_flood class DaemonClient(Client): def __init__(self, name: str, api_id: int, - api_hash: str, conn, **kwargs): + api_hash: str, conn, logger: BotLogger, + **kwargs + ): super().__init__(name, api_id, api_hash, **kwargs) self.db = DB(conn) + self.logger = logger @handle_flood diff --git a/daemon/tg.py b/daemon/tg.py index 5f8c21e..8382c29 100644 --- a/daemon/tg.py +++ b/daemon/tg.py @@ -11,17 +11,22 @@ from atom import Scraper from telegram.packages import DaemonClient from telegram.mailer import BotMutexes from telegram.mailer import Bot +from logger import BotLogger import os def main(): load_dotenv("telegram.env") + logger = BotLogger() + logger.init() + client = DaemonClient( "telegram/storage/EmailScraper", api_id=int(os.getenv("API_ID")), api_hash=os.getenv("API_HASH"), bot_token=os.getenv("BOT_TOKEN"), + logger=logger, conn=connector.connect( host=os.getenv("DB_HOST"), user=os.getenv("DB_USER"), -- Muhammad Rizki