from logging import LogRecord


class StreamFilter:
    def __init__(self, level: str) -> None:
        self._levels_dict: dict[int, str] = {50: "critical", 40: "error", 30: "warning", 20: "info", 10: "debug"}
        self._rev_levels_dict: dict[str, int] = {"critical": 50, "error": 40, "warning": 30, "info": 20, "debug": 10}
        self._level = level

    def filter(self, log_record: LogRecord) -> bool:
        return log_record.levelno <= self._rev_levels_dict[self._level.lower()]
