public function setLevel(string $level)
    {
        if (!defined(LogLevel::class . '::' . strtoupper($level)))
            throw new \DomainException("Invalid log level: $level");

        $this->level = $level;
        $this->level_num = self::$LEVEL_NUMERIC[$level];
        return $this;
    }