Skip to content

Commit

Permalink
Merge pull request #198 from synolia/fix/loggers
Browse files Browse the repository at this point in the history
Changed logger verbosity
  • Loading branch information
oallain authored Dec 9, 2024
2 parents 58ffeab + a21710e commit b1ab481
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function hasSupportedBuilder(string $attributeCode): bool
return true;
}
} catch (Throwable $throwable) {
$this->akeneoLogger->critical(sprintf(
$this->akeneoLogger->error(sprintf(
'AttributeValueBuilder "%s" failed to execute method support() for attribute "%s"',
$attributeValueBuilder::class,
$attributeCode,
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/TaxonAttribute/TaxonAttributeValueBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function hasSupportedBuilder(string $attributeCode): bool
return true;
}
} catch (Throwable $throwable) {
$this->akeneoLogger->critical(sprintf(
$this->akeneoLogger->error(sprintf(
'TaxonAttributeValueBuilder "%s" failed to execute method support() for attribute "%s"',
$attributeValueBuilder::class,
$attributeCode,
Expand Down
4 changes: 2 additions & 2 deletions src/Checker/Product/IsProductProcessableChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public function check(array $resource): bool
{
try {
if ('' === $resource['code'] || null === $resource['code']) {
$this->akeneoLogger->warning('Skipping product import because the code is missing.', ['resource' => $resource]);
$this->akeneoLogger->debug('Skipping product import because the code is missing.', ['resource' => $resource]);

return false;
}

if (!isset($resource['family'])) {
$this->akeneoLogger->warning('Skipping product import because the family is missing.', ['resource' => $resource]);
$this->akeneoLogger->debug('Skipping product import because the family is missing.', ['resource' => $resource]);

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/AbstractImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function preExecute(): void
throw new CommandLockedException(Messages::commandAlreadyRunning());
}

$this->akeneoLogger->notice($this->getName() ?? '');
$this->akeneoLogger->debug($this->getName() ?? '');

$this->pipeline = $this->pipelineFactory->create();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$batchPayload = new AssetPayload($this->clientFactory->createFromApiCredentials());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportAssociationTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$batchPayload = new AssociationTypePayload($this->clientFactory->createFromApiCredentials());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportAttributesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$attributePayload = new AttributePayload($this->clientFactory->createFromApiCredentials());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportCategoriesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$payload = new CategoryPayload($this->clientFactory->createFromApiCredentials());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportProductModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$productModelPayload = new ProductModelPayload($this->clientFactory->createFromApiCredentials());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BatchImportProductsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(
Assert::string($input->getArgument('ids'));
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$productModelPayload = new ProductPayload($this->clientFactory->createFromApiCredentials());
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ImportAssociationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ protected function execute(
return 0;
}

$this->akeneoLogger->notice($this->getName() ?? '');
$this->akeneoLogger->debug($this->getName() ?? '');

$payload = new AssociationPayload($this->clientFactory->createFromApiCredentials());
$this->associateProductsTask->__invoke($payload);

$this->akeneoLogger->notice(Messages::endOfCommand($this->getName() ?? ''));
$this->akeneoLogger->debug(Messages::endOfCommand($this->getName() ?? ''));
$this->release();

return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Task/SymfonyMessengerTaskHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function handleByPage(
$identifiers[] = $item['code'] ?? $item['identifier'];

if (0 === $count % $payload->getBatchSize()) {
$this->akeneoLogger->notice('Batching', ['codes' => $identifiers]);
$this->akeneoLogger->debug('Batching', ['codes' => $identifiers]);
$this->batch($payload, $items);
$items = [];
$identifiers = [];
Expand Down Expand Up @@ -96,7 +96,7 @@ private function handleByCursor(
$identifiers[] = $item['code'] ?? $item['identifier'];

if (0 === $count % $payload->getBatchSize()) {
$this->akeneoLogger->notice('Batching', ['codes' => $identifiers]);
$this->akeneoLogger->debug('Batching', ['codes' => $identifiers]);
$this->batch($payload, $items);
$items = [];
$identifiers = [];
Expand Down
10 changes: 5 additions & 5 deletions src/Handler/Task/SymfonyProcessTaskHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function batch(
$isTtySupported = Process::isTtySupported();
$process->setTty($isTtySupported);
$this->processManager->addProcess($process);
$this->akeneoLogger->info('Added batch process', [
$this->akeneoLogger->debug('Added batch process', [
'ids' => $ids,
]);

Expand Down Expand Up @@ -128,7 +128,7 @@ public function handle(
}

if ($count > 0 && count($ids) > 0 && $pipelinePayload->isBatchingAllowed() && $pipelinePayload->getProcessAsSoonAsPossible() && $pipelinePayload->allowParallel()) {
$this->akeneoLogger->notice('Batching', ['from_id' => $ids[0], 'to_id' => $ids[(is_countable($ids) ? \count($ids) : 0) - 1]]);
$this->akeneoLogger->debug('Batching', ['from_id' => $ids[0], 'to_id' => $ids[(is_countable($ids) ? \count($ids) : 0) - 1]]);
$this->batch($pipelinePayload, $ids);
$this->processManager->waitForAllProcesses();

Expand Down Expand Up @@ -184,7 +184,7 @@ private function handleByPage(
if ($payload->isBatchingAllowed() &&
$payload->getProcessAsSoonAsPossible() &&
0 === $count % $payload->getBatchSize()) {
$this->akeneoLogger->notice('Batching', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Batching', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->batch($payload, $ids);
$ids = [];
}
Expand All @@ -201,7 +201,7 @@ private function handleByCursor(
array &$ids = [],
): void {
foreach ($resourceCursor as $item) {
$this->akeneoLogger->info('Processing item ' . ($item['identifier'] ?? $item['code']));
$this->akeneoLogger->debug('Processing item ' . ($item['identifier'] ?? $item['code']));
++$count;
$sql = sprintf(
'INSERT INTO `%s` (`values`) VALUES (:values);',
Expand All @@ -216,7 +216,7 @@ private function handleByCursor(
if ($payload->isBatchingAllowed() &&
$payload->getProcessAsSoonAsPossible() &&
0 === $count % $payload->getBatchSize()) {
$this->akeneoLogger->notice('Batching', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug('Batching', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->batch($payload, $ids);
$ids = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function handleAsset(
);

if (!$asset instanceof Asset) {
$this->akeneoLogger->info('Created asset for product', [
$this->akeneoLogger->debug('Created asset for product', [
'product' => $model->getCode(),
'familyCode' => $assetFamilyCode,
'attributeCode' => $attributeCode,
Expand Down Expand Up @@ -156,7 +156,7 @@ private function handleAsset(
$oldContent = $asset->getContent();

if ($oldContent === $data) {
$this->akeneoLogger->info('Skipped asset for product as it has same content', [
$this->akeneoLogger->debug('Skipped asset for product as it has same content', [
'product' => $model->getCode(),
'familyCode' => $assetFamilyCode,
'attributeCode' => $attributeCode,
Expand Down Expand Up @@ -189,7 +189,7 @@ private function handleAsset(
$data,
);

$this->akeneoLogger->info('Updated asset for product', [
$this->akeneoLogger->debug('Updated asset for product', [
'product' => $model->getCode(),
'familyCode' => $assetFamilyCode,
'attributeCode' => $attributeCode,
Expand Down Expand Up @@ -228,7 +228,7 @@ private function addAssetToProduct(
}

if ($model->getAssets()->contains($asset)) {
$this->akeneoLogger->info('Asset already associated to product', [
$this->akeneoLogger->debug('Asset already associated to product', [
'product' => $model->getCode(),
'familyCode' => $assetFamilyCode,
'attributeCode' => $attributeCode,
Expand All @@ -242,7 +242,7 @@ private function addAssetToProduct(

$model->addAsset($asset);

$this->akeneoLogger->info('Associated asset to product', [
$this->akeneoLogger->debug('Associated asset to product', [
'product' => $model->getCode(),
'familyCode' => $assetFamilyCode,
'attributeCode' => $attributeCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Synolia\SyliusAkeneoPlugin\Checker\Product\IsProductProcessableCheckerInterface;
use Synolia\SyliusAkeneoPlugin\Event\Product\AfterProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Event\Product\BeforeProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Logger\Messages;
use Synolia\SyliusAkeneoPlugin\Processor\Product\ProductProcessorChainInterface;
use Synolia\SyliusAkeneoPlugin\Processor\ProductGroup\ProductGroupProcessor;
use Synolia\SyliusAkeneoPlugin\Processor\Resource\AkeneoResourceProcessorInterface;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function process(array $resource): void
}

try {
$this->akeneoLogger->notice('Processing product', [
$this->akeneoLogger->debug('Processing product', [
'code' => $resource['code'] ?? $resource['identifier'] ?? 'unknown',
]);

Expand All @@ -65,10 +64,6 @@ public function process(array $resource): void
$product = $this->getOrCreateEntity($resource);
$this->productProcessorChain->chain($product, $resource);

// TODO: check if id is null
$this->akeneoLogger->info(Messages::hasBeenCreated($product::class, (string) $product->getCode()));
$this->akeneoLogger->info(Messages::hasBeenUpdated($product::class, (string) $resource['code']));

$this->dispatcher->dispatch(new AfterProcessingProductEvent($resource, $product));
$this->entityManager->flush();
} catch (ORMInvalidArgumentException $ormInvalidArgumentException) {
Expand Down Expand Up @@ -104,7 +99,7 @@ private function handleProductGroup(array $resource): void
$this->entityManager->flush();
} catch (ORMInvalidArgumentException $ormInvalidArgumentException) {
if (!$this->entityManager->isOpen()) {
$this->akeneoLogger->warning('Recreating entity manager', ['exception' => $ormInvalidArgumentException]);
$this->akeneoLogger->error('Recreating entity manager', ['exception' => $ormInvalidArgumentException]);
$this->entityManager = $this->getNewEntityManager();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Asset/AssetAttributeTypeMatcherProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function match(string $type): AssetAttributeTypeMatcherInterface
return $typeMatcher;
}
} catch (\Throwable $throwable) {
$this->akeneoLogger->critical(\sprintf(
$this->akeneoLogger->error(\sprintf(
'AttributeTypeMatcher "%s" failed to execute method support() for attribute type "%s"',
$typeMatcher::class,
$type,
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/Asset/AssetValueBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public function hasSupportedBuilder(string $assetFamilyCode, string $assetCode):
return true;
}
} catch (UnsupportedAttributeTypeException $throwable) {
$this->akeneoLogger->info('Unsupported AssetAttributeType', [
$this->akeneoLogger->warning('Unsupported AssetAttributeType', [
'family_code' => $assetFamilyCode,
'asset_code' => $assetCode,
]);
} catch (\Throwable $throwable) {
$this->akeneoLogger->critical(\sprintf(
$this->akeneoLogger->error(\sprintf(
'AssetValueBuilderInterface "%s" failed to execute method support() for asset "%s" in family "%s"',
$attributeValueBuilder::class,
$assetCode,
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Filter/SearchFilterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function get(PayloadInterface $payload): array

$queryParameters = array_merge_recursive($queryParameters, $payload->getCustomFilters());

$this->akeneoLogger->notice('Filters', $queryParameters);
$this->akeneoLogger->debug('Filters', $queryParameters);

return $queryParameters;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Handler/Task/TaskHandlerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function provide(PipelinePayloadInterface $pipelinePayload): TaskHandlerI
{
foreach ($this->taskHandlers as $taskHandler) {
if ($taskHandler->support($pipelinePayload)) {
$this->akeneoLogger->notice($taskHandler::class);
$this->akeneoLogger->debug($taskHandler::class);

return $taskHandler;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Asset/BatchAssetTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
$this->retrieveAssets($payload, $resource);
$this->removeEntry($payload, (int) $result['id']);
} catch (\Throwable $throwable) {
$this->akeneoLogger->warning($throwable->getMessage());
$this->akeneoLogger->error($throwable->getMessage());
$this->removeEntry($payload, (int) $result['id']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Asset/ProcessAssetTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
return $payload;
}

$this->akeneoLogger->notice(Messages::retrieveFromAPI($payload->getType()));
$this->akeneoLogger->debug(Messages::retrieveFromAPI($payload->getType()));

$resources = $payload->getAkeneoPimClient()->getAssetFamilyApi()->all($this->searchFilterProvider->get($payload));

Expand Down
8 changes: 4 additions & 4 deletions src/Task/Association/AssociateProductsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
$productGroups = $this->productGroupRepository->findAll();

foreach ($productGroups as $productGroup) {
$this->akeneoLogger->info('Processing ProductGroup', [
$this->akeneoLogger->debug('Processing ProductGroup', [
'parent' => $productGroup->getModel(),
]);

$parentModel = $this->productRepository->findOneBy(['code' => $productGroup->getModel()]);

if (!$parentModel instanceof ProductInterface) {
$this->akeneoLogger->warning('Skipped ProductGroup', [
$this->akeneoLogger->debug('Skipped ProductGroup', [
'parent' => $productGroup->getModel(),
]);

Expand All @@ -66,7 +66,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
/** @var ProductAssociationTypeInterface $productAssociationType */
$productAssociationType = $this->productAssociationTypeRepository->findOneBy(['code' => $associationType]);

$this->akeneoLogger->info('Processing ProductAssociationType', [
$this->akeneoLogger->debug('Processing ProductAssociationType', [
'code' => $associationType,
'name' => $productAssociationType->getName() ?? '',
]);
Expand Down Expand Up @@ -127,7 +127,7 @@ private function retrieveModels(
foreach ($associationProductGroup->getProducts() as $product) {
$models[] = $product;

$this->akeneoLogger->info('Added product to association group', [
$this->akeneoLogger->debug('Added product to association group', [
'association_code' => $productAssociationType->getCode(),
'code' => $product->getCode(),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Task/AssociationType/BatchAssociationTypesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
{
$this->akeneoLogger->debug(self::class);
$type = $payload->getType();
$this->akeneoLogger->notice(Messages::createOrUpdate($type));
$this->akeneoLogger->debug(Messages::createOrUpdate($type));

$query = $this->getSelectStatement($payload);
/** @var Result $queryResult */
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Attribute/BatchAttributesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __invoke(PipelinePayloadInterface $payload): PipelinePayloadInte
{
$this->akeneoLogger->debug(self::class);
$type = $payload->getType();
$this->akeneoLogger->notice(Messages::createOrUpdate($type));
$this->akeneoLogger->debug(Messages::createOrUpdate($type));

$query = $this->getSelectStatement($payload);
/** @var Result $queryResult */
Expand Down
Loading

0 comments on commit b1ab481

Please sign in to comment.