Fix logger classes and tests

This commit is contained in:
Philipp 2023-07-17 01:06:11 +02:00
parent 903ecc2a76
commit bca6abf4ab
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
5 changed files with 28 additions and 72 deletions

View file

@ -21,6 +21,8 @@
namespace Friendica\Core\Logger\Util;
use Friendica\Core\Logger\Exception\LoggerUnusableException;
/**
* Util class for filesystem manipulation for Logger classes
*/
@ -37,6 +39,8 @@ class FileSystem
* @param string $file The file
*
* @return string The directory name (empty if no directory is found, like urls)
*
* @throws LoggerUnusableException
*/
public function createDir(string $file): string
{
@ -57,7 +61,7 @@ class FileSystem
restore_error_handler();
if (!$status && !is_dir($dirname)) {
throw new \UnexpectedValueException(sprintf('Directory "%s" cannot get created: ' . $this->errorMessage, $dirname));
throw new LoggerUnusableException(sprintf('Directory "%s" cannot get created: ' . $this->errorMessage, $dirname));
}
return $dirname;
@ -75,7 +79,7 @@ class FileSystem
*
* @return resource the open stream resource
*
* @throws \UnexpectedValueException
* @throws LoggerUnusableException
*/
public function createStream(string $url)
{
@ -89,7 +93,7 @@ class FileSystem
restore_error_handler();
if (!is_resource($stream)) {
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: ' . $this->errorMessage, $url));
throw new LoggerUnusableException(sprintf('The stream or file "%s" could not be opened: ' . $this->errorMessage, $url));
}
return $stream;