pronoun-o-matic/plugins/log_plugin.py

22 lines
604 B
Python
Raw Normal View History

2022-06-04 22:18:32 +02:00
import logging
from pronoun_update import PronounUpdate
from typing import Any
from plugin import Plugin
class LogPlugin(Plugin):
log_level: int
@classmethod
def name(cls) -> str:
return "log"
def __init__(self, config: dict[str, Any]):
log_level_str = config.get("level", "INFO")
self.log_level = logging.getLevelName(log_level_str)
""" A simple plugin that simply logs the pronoun update """
async def update_bio(self, pronoun_update: PronounUpdate) -> None:
logging.log(self.log_level, f"Updating pronouns to: {pronoun_update.pronouns}")