class LogFileManager in File Log 8
Same name in this branch
- 8 src/LogFileManager.php \Drupal\filelog\LogFileManager
- 8 src/ProxyClass/LogFileManager.php \Drupal\filelog\ProxyClass\LogFileManager
Same name and namespace in other branches
- 2.0.x src/LogFileManager.php \Drupal\filelog\LogFileManager
Provide file-handling methods for the logfile.
This is a separate service to allow it to be injected into the logger as a proxy and circumvent the circular dependency between logger and file system.
Hierarchy
- class \Drupal\filelog\LogFileManager implements LogFileManagerInterface
Expanded class hierarchy of LogFileManager
2 files declare their use of LogFileManager
- FileLogRotationTest.php in tests/
src/ Unit/ FileLogRotationTest.php - FileLogTest.php in tests/
src/ Unit/ FileLogTest.php
1 string reference to 'LogFileManager'
1 service uses LogFileManager
File
- src/
LogFileManager.php, line 14
Namespace
Drupal\filelogView source
class LogFileManager implements LogFileManagerInterface {
public const FILENAME = 'drupal.log';
/**
* The filelog settings.
*
* @var \Drupal\Core\Config\Config
*/
protected $config;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* LogFileManager constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config_factory service.
* @param \Drupal\Core\File\FileSystemInterface $fileSystem
* The file_system service.
*/
public function __construct(ConfigFactoryInterface $configFactory, FileSystemInterface $fileSystem) {
$this->config = $configFactory
->get('filelog.settings');
$this->fileSystem = $fileSystem;
}
/**
* {@inheritdoc}
*/
public function getFileName() : string {
return $this->config
->get('location') . '/' . static::FILENAME;
}
/**
* {@inheritdoc}
*/
public function ensurePath() : bool {
$path = $this->config
->get('location');
return $this->fileSystem
->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LogFileManager:: |
protected | property | The filelog settings. | |
LogFileManager:: |
protected | property | The file system service. | |
LogFileManager:: |
public | function |
Ensure that the log directory exists. Overrides LogFileManagerInterface:: |
|
LogFileManager:: |
public | constant | ||
LogFileManager:: |
public | function |
Get the complete filename of the log. Overrides LogFileManagerInterface:: |
|
LogFileManager:: |
public | function | LogFileManager constructor. |