. * --------------------------------------------------------------------- */ namespace Glpi\System\Requirement; use Psr\Log\LoggerInterface; if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * @since 9.5.0 */ class LogsWriteAccess extends AbstractRequirement { /** * Logger. * * @var LoggerInterface */ private $logger; /** * * @param LoggerInterface $logger */ public function __construct(LoggerInterface $logger) { $this->logger = $logger; $this->title = __('Checking write permissions for log files'); } protected function check() { // Only write test for GLPI_LOG as SElinux prevent removing log file. try { $this->logger->warning('Test logger'); $this->validated = true; $this->validation_messages[] = __('The log file has been created successfully.'); } catch (\UnexpectedValueException $e) { $this->validated = false; $this->validation_messages[] = sprintf(__('The log file could not be created in %s.'), GLPI_LOG_DIR); } } }