public function logCommand($command, $duration, $connection, $error = false)
    {
        ++$this->nbCommands;

        if (null !== $this->logger) {
            $this->commands[] = array('cmd' => $command, 'executionMS' => $duration, 'conn' => $connection, 'error' => $error);
            if ($error) {
                $message = 'Command "' . $command . '" failed (' . $error . ')';

                $this->logger->error($message);
            } else {
                $this->logger->debug('Executing command "' . $command . '"');
            }
        }
    }