pronoun-o-matic/plugins/log_plugin.py
2022-06-05 21:50:55 +02:00

21 lines
612 B
Python

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