final class ApigeeEdgeDebugToFileLogger in Apigee Edge 8
Logs Apigee Edge debug messages to a file in the root of Drupal.
Hierarchy
- class \Drupal\syslog\Logger\SysLog implements \Psr\Log\LoggerInterface uses RfcLoggerTrait
- class \Drupal\apigee_edge_test\Logger\ApigeeEdgeDebugToFileLogger
Expanded class hierarchy of ApigeeEdgeDebugToFileLogger
1 string reference to 'ApigeeEdgeDebugToFileLogger'
- 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 ApigeeEdgeDebugToFileLogger
- logger.apigee_edge_test_apigee_edge_debug_to_file in tests/
modules/ apigee_edge_test/ apigee_edge_test.services.yml - Drupal\apigee_edge_test\Logger\ApigeeEdgeDebugToFileLogger
File
- tests/
modules/ apigee_edge_test/ src/ Logger/ ApigeeEdgeDebugToFileLogger.php, line 31
Namespace
Drupal\apigee_edge_test\LoggerView source
final class ApigeeEdgeDebugToFileLogger extends SysLog {
/**
* The database service.
*
* @var \Drupal\Core\Database\Connection
*/
private $database;
/**
* ApigeeEdgeDebugToFileLogger 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}
*/
public function log($level, $message, array $context = []) {
// Only log messages from our debug module.
if ($context['channel'] === 'apigee_edge_debug') {
parent::log($level, $message, $context);
}
}
/**
* {@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 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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ApigeeEdgeDebugToFileLogger:: |
private | property | The database service. | |
ApigeeEdgeDebugToFileLogger:: |
public | function |
Logs with an arbitrary level. Overrides SysLog:: |
|
ApigeeEdgeDebugToFileLogger:: |
protected | function |
A syslog wrapper to make syslog functionality testable. Overrides SysLog:: |
|
ApigeeEdgeDebugToFileLogger:: |
public | function |
ApigeeEdgeDebugToFileLogger constructor. Overrides SysLog:: |
|
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:: |
protected | function | Opens a connection to the system logger. |