private function log($msg, $exception = null)
    {
        if (!$this->config->isEnableLog()) {
            return false;
        }

        if (empty($this->logger) && !empty($this->config->getLogFilePath())) {
            $this->logger = new DefaultLogger($this->config->getLogFilePath());
        }

        if ($exception) {
            $this->logger->log(LogLevel::ALERT, $msg, ['exception' => $exception]);
        } else {
            $this->logger->log(LogLevel::DEBUG, $msg, []);
        }

        return true;
    }