From: kaliko Date: Thu, 23 Mar 2023 16:36:24 +0000 (+0100) Subject: Expose class attribute to set plugin log level X-Git-Tag: 0.3.0~2 X-Git-Url: https://git.kaliko.me/?p=sid.git;a=commitdiff_plain;h=a8273fcb65b081ee9ebda42a0f39f071850d8f66 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 --- 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"""