You are here

protected function ApigeeEdgeDebugToFileLogger::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/ApigeeEdgeDebugToFileLogger.php, line 68

Class

ApigeeEdgeDebugToFileLogger
Logs Apigee Edge debug messages to a file in the root of Drupal.

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 prefix to the log file.
  $log_path .= '/apigee_edge_debug-' . 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);
}