/** * Touch a state document (make sure that it exists). * * @param string $key * State document key. * @return bool True if document exists. */ public function touch($key) { if (!isset($this->files[$key])) { if (!Utilities::dirExists($this->dir, true)) { return false; } $this->files[$key] = new PhpStore($this->dir . '/' . $key . '.php'); } return $this->files[$key]->touch(); }
/** * Construct file log handler. * @param string $filePath Log file path. * @param string $level Minimum log level, see {@see \Psr\Log\LogLevel}. * @param bool $useLocking Whether to lock the file before appending to ensure * atomicity of each write. */ public function __construct($filePath, $level = LogLevel::DEBUG, $useLocking = false) { if (!file_exists($filePath)) { $dir = dirname($filePath); if (!Utilities::dirExists($dir)) { trigger_error('Could not create log directory: ' . $dir, E_USER_WARNING); $this->stream = false; return; } if (!touch($filePath)) { trigger_error('Could not create log file: ' . $filePath, E_USER_WARNING); $this->stream = false; return; } } $this->file = realpath($filePath); parent::__construct(null, $level, $useLocking); }