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):
|
2022-06-05 21:50:45 +02:00
|
|
|
"""A simple plugin that simply logs the pronoun update"""
|
|
|
|
|
2022-06-04 22:18:32 +02:00
|
|
|
log_level: int
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def name(cls) -> str:
|
|
|
|
return "log"
|
|
|
|
|
2022-06-05 21:50:45 +02:00
|
|
|
def _load_from_config(self, config: dict[str, Any]) -> None:
|
2022-06-04 22:18:32 +02:00
|
|
|
log_level_str = config.get("level", "INFO")
|
|
|
|
self.log_level = logging.getLevelName(log_level_str)
|
|
|
|
|
2022-06-05 21:50:45 +02:00
|
|
|
def update_bio(self, pronoun_update: PronounUpdate) -> None:
|
2022-06-04 22:18:32 +02:00
|
|
|
logging.log(self.log_level, f"Updating pronouns to: {pronoun_update.pronouns}")
|