Parse a log line to extract query information

@param string $message

@return array
357333
protected function parseAndLogSqlQuery($message)
    {
        $parts = explode('|', $message, 4);
        $sql   = trim($parts[3]);

        $duration = 0;
        if (preg_match('/([0-9]+\.[0-9]+)/', $parts[1], $matches)) {
            $duration = (float) $matches[1];
        }

        $memory = 0;
        if (preg_match('/([0-9]+\.[0-9]+) ([A-Z]{1,2})/', $parts[2], $matches)) {
            $memory = (float) $matches[1];
            if ($matches[2] == 'KB') {
                $memory *= 1024;
            } elseif ($matches[2] == 'MB') {
                $memory *= 1024 * 1024;
            }
        }

        $this->statements[]    = [
            'sql'          => $sql,
            'is_success'   => true,
            'duration'     => $duration,
            'duration_str' => $this->formatDuration($duration),
            'memory'       => $memory,
            'memory_str'   => $this->formatBytes($memory),
        ];
        $this->accumulatedTime += $duration;
        $this->peakMemory      = max($this->peakMemory, $memory);
        return [$sql, $this->formatDuration($duration)];
    }
1365570
public static function prepareMessage($message)
    {
        if (method_exists($message, '__toString')) {
            return $message->__toString();
        }

        if (is_scalar($message)) {
            return (string)$message;
        }

        if (class_exists(VarDumper::class)) {
            return VarDumper::export($message);
        }

        throw new InvalidArgumentException('The log message MUST be a string or object implementing __toString()');
    }
420569
public function info($message, array $context = array()) {
        $context['fromClass'] = get_called_class();
        foreach ($this->loggersInstances as $logger) {
            $logger->info($message, $context);
        }
    }
1069376
public function logMessage(Message $message) {
        foreach($this->logger as $logger) {
            $logger->logMessage($message);
        }
    }
105358
private function parseMessage($message)
    {
        $string = $message;

        if (is_array($message)) {
            $format = '"%s" %s';
            $errors = array();

            foreach ($message as $field => $messages) {
                if (is_array($messages)) {
                    $messages = array_unique($messages);
                    foreach ($messages as $error) {
                        $errors[] = sprintf($format, $field, $error);
                    }
                } elseif (is_integer($field)) {
                    $errors[] = $messages;
                } else {
                    $errors[] = sprintf($format, $field, $messages);
                }
            }

            $string = implode(', ', $errors);
        }

        return $string;
    }
104569
protected function buildView($message)
    {
        if ($message->view) {
            return $message->view;
        }

        return [
            'html' => $this->markdown->render($message->markdown, $message->data()),
            'text' => $this->markdown->renderText($message->markdown, $message->data()),
        ];
    }
1023936
protected function formatMessage($message)
    {
        $traces = array();
        foreach ($this->getBacktrace() as $trace) {
            $traces[] = "in {$trace['file']}:{$trace['line']}";
        }

        $str = "[" . date('Y-m-d H:i:s', time()) . "]#" .  $this->getUserIp() . "# - " . $message;
        $str .= (empty($traces) ? '' : "\n    " . implode("\n    ", $traces));
        return $str;
    }
815175
private function parseRawMessage($message) {
		$positionStartBody = strpos($message, "\r\n\r\n");

		$startPositionOffset = 4;
		if ($positionStartBody === false) {
			$positionStartBody = strpos($message, "\n\n");
			$startPositionOffset = 2;
			if ($positionStartBody === false) {
				throw new \Exception("Invalid HTTP message provided. It does not contain a header part.");
			}
		}

		$headerString = str_replace("\r\n", "\n", trim(substr($message, 0, $positionStartBody), "\r\n"));
		$content = substr($message, $positionStartBody + $startPositionOffset);

		$this->headers = $this->parseHttpHeaders($headerString);
		$statusLine = current(explode("\n", $headerString));
		$this->parseStatusLine($statusLine);
		$this->body = $content;
	}
614016
protected function logToFile($message){
        if(isset($this->logger) && $this->logger instanceof \sb\Logger\Base){
            return $this->logger->{$this->log_name}($message);
        }
    }
1234610
private function log($message)
    {
        if (!is_null($this->logger)) {
            $this->logger->log(
                LogLevel::DEBUG,
                sprintf("[%s] - %s", date('Y-m-d H:i:s'), $message)
            );
        }
    }
1232812
private function formatMessage($message)
    {
        $formattedMessage = implode('', (array)$message);
        $formattedMessage = str_replace(PHP_EOL, '', $formattedMessage);
        $formattedMessage = strip_tags($formattedMessage);
        $formattedMessage = preg_replace([
            '/\\x1b[[][^A-Za-z]*[A-Za-z]/',
            '/[-=]{2,}/',
        ], '', $formattedMessage);

        return $formattedMessage !== null
            ? trim($formattedMessage, " \t\n\r\0\x0B-=")
            : (string)$formattedMessage;
    }
858122
public function formatMessage(array $message): string
    {
        [$level, $text, $context] = $message;
        $category = $context['category'];
        $timestamp = $context['time'];
        $level = Logger::getLevelName($level);
        $traces = [];
        if (isset($context['trace'])) {
            foreach ($context['trace'] as $trace) {
                $traces[] = "in {$trace['file']}:{$trace['line']}";
            }
        }

        $prefix = $this->getMessagePrefix($message);

        return $this->getTime($timestamp) . " {$prefix}[$level][$category] $text"
            . (empty($traces) ? '' : "\n    " . implode("\n    ", $traces));
    }
720515
protected function formatMessage($message)
    {
        if (is_array($message)) {
            $message = var_export($message, true);
        } elseif (is_object($message)) {
            $message = get_object_vars($message);
        }

        return $message;
    }
312640
public function log($message, $args, $priority='LOG_INFO')
    {
        if (array_key_exists('FILENAME', $args) === false) {
            $backtrace        = debug_backtrace();
            $args['FILENAME'] = $backtrace[0]['file'];
            $args['LINENO']   = $backtrace[0]['line'];
        }//end if

        $newArgs   = array();
        $fileParts = explode('/', $args['FILENAME']);
        $newArgs[] = array_pop($fileParts)."#".$args['LINENO'];
        unset($args['LINENO']);
        unset($args['FILENAME']);
        foreach ($args as $arg) {
            $newArgs[] = $arg;
        }//end foreach

        if ($this->_isSecure($message) === true) {
            // TODO: Do not write log
            // Get list of handlers which will process message
            // Send message about which handlers are erroneous.
        } else {
            if (empty($this->_logPatterns)) {
                $this->_logPatterns[Logger::ALL] = new FileLogHandler();
            }//end if

            foreach ($this->_logPatterns as $pattern => $handler) {
                if(preg_match($pattern, $message))
                    $handler->writeLog($message, $priority, $newArgs);
            }//end foreach
        }
    }
403146
public function logMessage($message)
    {
        $this->logger->info(strip_tags($message));

        if ($this->sendToBrowser) {
            $this->sendMessageToBrowser($message);
        }

        if ($this->sendToCli) {
            $this->sendMessageToCli($message);
        }
    }
317351
public static function log($message, string $priority = self::INFO): ?string
    {
        $logger = self::sendToLogger(self::getLogger(), $priority, $message);

        if ($logger instanceof Logger) {
            return $logger->getLastExceptionFile();
        }

        return null;
    }
1032648
public function error($message)
    {
        $args = func_get_args();
        array_shift($args);
        return $this->log(Log::Error, $message, $args);
    }