Skip to content

Commit

Permalink
Improve debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns committed Feb 17, 2022
1 parent 905bad7 commit 931f78f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Classes/Service/AssetUpdateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ private function replaceAsset(string $identifier): void
try {
$this->flushProxyForAsset($identifier);
$proxy = $this->getAssetSource()->getAssetProxyRepository()->getAssetProxy($identifier);
$assetResource = $this->resourceManager->importResource($proxy->getImportStream());
$newResource = $this->resourceManager->importResource($proxy->getImportStream());
} catch (\Exception $e) {
$this->logger->debug(sprintf('Could not replace resource on %s from %s, exception: %s', $localAssetIdentifier, $identifier, $this->throwableStorage->logThrowable($e)), LogEnvironment::fromMethodName(__METHOD__));;
$this->logger->debug(sprintf('Could not import resource for asset %s from %s, exception: %s', $localAssetIdentifier, $identifier, $this->throwableStorage->logThrowable($e)), LogEnvironment::fromMethodName(__METHOD__));;
throw $e;
}
$assetResource->setFilename($proxy->getFilename());
$this->assetService->replaceAssetResource($localAsset, $assetResource);
$newResource->setFilename($proxy->getFilename());
$this->assetService->replaceAssetResource($localAsset, $newResource);
$this->logger->debug(sprintf('Replaced resource %s with %s on asset %s from Canto asset %s', $localAsset->getResource()->getSha1(), $newResource->getSha1(), $localAssetIdentifier, $identifier), LogEnvironment::fromMethodName(__METHOD__));

// … to delete it here!
$this->logger->debug(sprintf('Trying to delete replaced resource: %s (%s)', $previousResource->getFilename(), $previousResource->getSha1()), LogEnvironment::fromMethodName(__METHOD__));;
$this->resourceManager->deleteResource($previousResource);

$this->logger->debug(sprintf('Replaced resource on %s from %s', $localAssetIdentifier, $identifier), LogEnvironment::fromMethodName(__METHOD__));
}

private function buildIdentifier(string $scheme, string $identifier): string
Expand Down

0 comments on commit 931f78f

Please sign in to comment.