Skip to content

Commit

Permalink
chore: add error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
augustas committed Oct 23, 2024
1 parent 45e5f47 commit 6e33eee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions common/oatbox/filesystem/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function deleteSelf()
$this->getFileSystem()->deleteDirectory($this->getPrefix());
return true;
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}

return false;
Expand Down
12 changes: 10 additions & 2 deletions common/oatbox/filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace oat\oatbox\filesystem;

use common_Logger;
use GuzzleHttp\Psr7\Stream;
use GuzzleHttp\Psr7\StreamWrapper;
use Psr\Http\Message\StreamInterface;
Expand Down Expand Up @@ -53,6 +54,7 @@ public function getMimeType()

return $mimeType;
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}
return false;
}
Expand Down Expand Up @@ -109,6 +111,7 @@ public function write($mixed, $mimeType = null)
));
}
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
return false;
}

Expand All @@ -131,7 +134,7 @@ public function update($mixed, $mimeType = null)
throw new \RuntimeException('File "' . $this->getPrefix() . '" not found."');
}

\common_Logger::i('Writing in ' . $this->getPrefix());
common_Logger::i('Writing in ' . $this->getPrefix());

return $this->write($mixed, $mimeType);
}
Expand All @@ -148,7 +151,7 @@ public function update($mixed, $mimeType = null)
*/
public function put($mixed, $mimeType = null)
{
\common_Logger::i('Writting in ' . $this->getPrefix());
common_Logger::i('Writting in ' . $this->getPrefix());

return $this->write($mixed, $mimeType);
}
Expand All @@ -163,6 +166,7 @@ public function read()
try {
return $this->getFileSystem()->read($this->getPrefix());
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}

return false;
Expand All @@ -178,6 +182,7 @@ public function readStream()
try {
return $this->getFileSystem()->readStream($this->getPrefix());
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}

return false;
Expand All @@ -194,6 +199,7 @@ public function readPsrStream()
try {
$resource = $this->getFileSystem()->readStream($this->getPrefix());
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}

return new Stream($resource);
Expand All @@ -204,6 +210,7 @@ public function exists(): bool
try {
return $this->getFileSystem()->fileExists($this->getPrefix());
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}
return false;
}
Expand All @@ -214,6 +221,7 @@ public function delete(): bool
$this->getFileSystem()->delete($this->getPrefix());
return true;
} catch (FilesystemException $e) {
$this->logWarning($e->getMessage());
}

return false;
Expand Down
4 changes: 3 additions & 1 deletion common/oatbox/filesystem/FileSystemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace oat\oatbox\filesystem;

use oat\oatbox\log\LoggerAwareTrait;
use oat\oatbox\service\ServiceManager;
use ReflectionClass;
use ReflectionProperty;
Expand All @@ -31,8 +32,9 @@
abstract class FileSystemHandler implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
use LoggerAwareTrait;

private const NOT_SERIALIZABLE_PROPERTIES = ['fileSystem', 'serviceLocator'];
private const NOT_SERIALIZABLE_PROPERTIES = ['fileSystem', 'serviceLocator', 'logger'];

/**
* @var mixed
Expand Down

0 comments on commit 6e33eee

Please sign in to comment.