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 kanazawa.. (unknown [101.128.126.198]) by gnuweeb.org (Postfix) with ESMTPSA id 9097280632; Fri, 4 Nov 2022 18:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667585398; bh=rmnlDun6QZZazGaBAcjX+RkXn1KN96TdTo8vgnVRgYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJ+sKmHKg3fnUwwrBekymvo4lQVB2m7BDBG7lVECkcXfKRHUBJyfn+MuQNCx3K5BU iuBuPoQQUT/EhXHrUkjolWJTIS71zAS/AmHQ2KUZsv1f7xE3dRKTkaBNQGyFzf6ynN bOTOJjxzFItmwMGt9l/4mM+oQP6ZMHtgy1qvZA5cIBWvcEtSXQsGcOWWJfd+Xt04np SgbV/CSzVAK9PN/FheABhNwqXs+3Rh13bHA9i/cOpH54KN8UN32p3QYGImcY96nDl2 dn27AznGqQveOMuENv8fdNODzawqPkURBUmC3byzLMi+qxIRsc5HRxVW0PbXMYksUI GOasA2jcF3iRg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 08/16] telegram: Use the created BotLogger() class Date: Sat, 5 Nov 2022 01:09:15 +0700 Message-Id: <20221104180931.3852-9-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221104180931.3852-1-kiizuha@gnuweeb.org> References: <20221104180931.3852-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