You are here

protected function SyslogToFileLogger::syslogWrapper in Apigee Edge 8

A syslog wrapper to make syslog functionality testable.

Parameters

int $level: The syslog priority.

string $entry: The message to send to syslog function.

Overrides SysLog::syslogWrapper

File

tests/modules/apigee_edge_test/src/Logger/SyslogToFileLogger.php, line 58

Class

SyslogToFileLogger
Redirects Drupal logs to a file.

Namespace

Drupal\apigee_edge_test\Logger

Code

protected function syslogWrapper($level, $entry) {
  $log_path = getenv('APIGEE_EDGE_TEST_LOG_DIR');
  if (!$log_path) {
    $log_path = \Drupal::service('file_system')
      ->realpath('public://');
  }

  // Add test id as a suffix to the log file.
  $log_path .= '/syslog-' . str_replace('test', '', $this->database
    ->tablePrefix()) . '.log';

  // Do not fail a test just because the fail is not writable.
  @error_log($entry . PHP_EOL, 3, $log_path);
}