You are here

public function LagoonLogger::log in Lagoon Logs 7

Parameters

$logEntry:

File

lib/LagoonLogger.php, line 117

Class

LagoonLogger

Code

public function log($logEntry) {
  global $base_url;
  $formatter = new LagoonLogstashFormatter($this
    ->getHostProcessIndex());
  $message = !is_null($logEntry['variables']) ? strtr($logEntry['message'], $logEntry['variables']) : $logEntry['message'];
  $processorData = $this
    ->transformDataForProcessor($logEntry, $message, $base_url);
  try {
    LagoonLogstashPusher::pushUdp($this->hostName, $this->hostPort, $formatter
      ->format($processorData));
  } catch (Exception $exception) {
    $logMessage = sprintf("Unable to reach %s to log: %s", $this->hostName . ":" . $this->hostPort, json_encode([
      $message,
      $processorData,
    ]));
    self::logWatchdogFallbackMessage($logMessage);
  }
}