from __future__ import annotations

from datetime import datetime


class Logger:
    def __init__(self, *, quiet: bool = False, debug: bool = False) -> None:
        self.quiet = quiet
        self.debug_enabled = debug

    def _ts(self) -> str:
        return datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    def _log(self, level: str, msg: str) -> None:
        if self.quiet and level not in ("ERROR",):
            return
        print(f"[{self._ts()}] {level:<5} {msg}", flush=True)

    def info(self, msg: str) -> None:
        self._log("INFO", msg)

    def warn(self, msg: str) -> None:
        self._log("WARN", msg)

    def error(self, msg: str) -> None:
        self._log("ERROR", msg)

    def debug(self, msg: str) -> None:
        if self.debug_enabled:
            self._log("DEBUG", msg)
