final class SyslogToFileLogger in Apigee Edge 8
Redirects Drupal logs to a file.
Hierarchy
- class \Drupal\syslog\Logger\SysLog implements \Psr\Log\LoggerInterface uses RfcLoggerTrait
- class \Drupal\apigee_edge_test\Logger\SyslogToFileLogger
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\LoggerView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
SysLog:: |
protected | property | A configuration object containing syslog settings. | |
SysLog:: |
protected | property | Stores whether there is a system logger connection opened or not. | |
SysLog:: |
protected | property | The message's placeholders parser. | |
SysLog:: |
public | function |
Logs with an arbitrary level. Overrides RfcLoggerTrait:: |
|
SysLog:: |
protected | function | Opens a connection to the system logger. | |
SyslogToFileLogger:: |
private | property | The database service. | |
SyslogToFileLogger:: |
protected | function |
A syslog wrapper to make syslog functionality testable. Overrides SysLog:: |
|
SyslogToFileLogger:: |
public | function |
SyslogToFileLogger constructor. Overrides SysLog:: |