Skip to content

Instantly share code, notes, and snippets.

@kinglozzer
Last active July 1, 2019 15:47
Show Gist options
  • Save kinglozzer/a9334ae31a7e544f4ba397888503fcb1 to your computer and use it in GitHub Desktop.
Save kinglozzer/a9334ae31a7e544f4ba397888503fcb1 to your computer and use it in GitHub Desktop.
InterventionBackend logging
diff --git a/src/InterventionBackend.php b/src/InterventionBackend.php
index 81bcd97..dc251bc 100644
--- a/src/InterventionBackend.php
+++ b/src/InterventionBackend.php
@@ -13,6 +13,7 @@ use Intervention\Image\Size;
use InvalidArgumentException;
use LogicException;
use Psr\Http\Message\StreamInterface;
+use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;
use SilverStripe\Assets\Storage\AssetContainer;
use SilverStripe\Assets\Storage\AssetStore;
@@ -271,6 +272,10 @@ class InterventionBackend implements Image_Backend, Flushable
// Handle unsupported image encoding on load (will be marked as failed)
// Unsupported exceptions are handled without being raised as exceptions
$error = self::FAILED_INVALID;
+
+ if (Injector::inst()->has(LoggerInterface::class.'.InterventionBackend')) {
+ Injector::inst()->get(LoggerInterface::class.'.InterventionBackend')->error($ex->getMessage(), ['exception' => $ex]);
+ }
} finally {
if ($error) {
$this->markFailed($hash, $variant, $error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment