You are here

final class SyslogToFileLogger in Apigee Edge 8

Redirects Drupal logs to a file.

Hierarchy

Expanded class hierarchy of SyslogToFileLogger

1 string reference to 'SyslogToFileLogger'
apigee_edge_test.services.yml in tests/modules/apigee_edge_test/apigee_edge_test.services.yml
tests/modules/apigee_edge_test/apigee_edge_test.services.yml
1 service uses SyslogToFileLogger
logger.apigee_edge_test_syslog_to_file in tests/modules/apigee_edge_test/apigee_edge_test.services.yml
Drupal\apigee_edge_test\Logger\SyslogToFileLogger

File

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

Namespace

Drupal\apigee_edge_test\Logger
View source
final class SyslogToFileLogger extends SysLog {

  /**
   * The database service.
   *
   * @var \Drupal\Core\Database\Connection
   */
  private $database;

  /**
   * SyslogToFileLogger constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   A configuration factory instance.
   * @param \Drupal\Core\Logger\LogMessageParserInterface $parser
   *   The parser to use when extracting message variables.
   * @param \Drupal\Core\Database\Connection $database
   *   The database service.
   */
  public function __construct(ConfigFactoryInterface $config_factory, LogMessageParserInterface $parser, Connection $database) {
    parent::__construct($config_factory, $parser);
    $this->database = $database;
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RfcLoggerTrait::alert public function
RfcLoggerTrait::critical public function
RfcLoggerTrait::debug public function
RfcLoggerTrait::emergency public function
RfcLoggerTrait::error public function
RfcLoggerTrait::info public function
RfcLoggerTrait::notice public function
RfcLoggerTrait::warning public function
SysLog::$config protected property A configuration object containing syslog settings.
SysLog::$connectionOpened protected property Stores whether there is a system logger connection opened or not.
SysLog::$parser protected property The message's placeholders parser.
SysLog::log public function Logs with an arbitrary level. Overrides RfcLoggerTrait::log
SysLog::openConnection protected function Opens a connection to the system logger.
SyslogToFileLogger::$database private property The database service.
SyslogToFileLogger::syslogWrapper protected function A syslog wrapper to make syslog functionality testable. Overrides SysLog::syslogWrapper
SyslogToFileLogger::__construct public function SyslogToFileLogger constructor. Overrides SysLog::__construct