From a8273fcb65b081ee9ebda42a0f39f071850d8f66 Mon Sep 17 00:00:00 2001 From: kaliko Date: Thu, 23 Mar 2023 17:36:24 +0100 Subject: [PATCH] Expose class attribute to set plugin log level To enable debug level for RTBL plugin only: >>> import logging >>> from sid.rtbl import RTBL >>> RTBL.log_level = logging.DEBUG Then instanciate the bot and register plugins --- sid/plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sid/plugin.py b/sid/plugin.py index dd452e5..f314aca 100644 --- a/sid/plugin.py +++ b/sid/plugin.py @@ -2,6 +2,7 @@ # SPDX-FileCopyrightText: 2010, 2011 Anaël Verrier # SPDX-FileCopyrightText: 2014, 2020, 2023 kaliko +import logging from slixmpp.exceptions import XMPPError @@ -17,12 +18,16 @@ class Plugin: :param sid.sid.MUCBot bot: bot the plugin is load from """ + #: Overriding bot log level for the plugin + log_level = None def __init__(self, bot): self.bot = bot self.log = bot.log.getChild(self.__class__.__name__) #: :py:obj:`list` : List of tuples (event, handler) self.handlers = [] + if self.log_level: + self.log.setLevel(self.log_level) def add_handlers(self): """Add handlers declared in self.hanlders""" -- 2.39.2