Skip to content

Commit

Permalink
Merge pull request #35 from ho-nl/TEN-738
Browse files Browse the repository at this point in the history
fix(TEN-738): update deleted methods of monolog logger
  • Loading branch information
Maikel-Koek authored Feb 16, 2023
2 parents d6a616c + 5a4e274 commit 0145aab
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 38 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"guzzlehttp/guzzle": "^7",
"prewk/xml-string-streamer": "^1.2",
"prewk/xml-string-streamer-guzzle": "^1.2",
"kevinrob/guzzle-cache-middleware": "^1.4",
"kevinrob/guzzle-cache-middleware": "^4",
"ecomdev/magento-psr6-bridge": "^0.2.1",
"symfony/stopwatch": "~4.0",
"bakame/psr7-csv-factory": "^1.0@dev",
"league/csv": "^9.1"
"league/csv": "^9.1",
"monolog/monolog": "^2.8"
},
"type": "magento2-module",
"autoload": {
Expand Down
12 changes: 6 additions & 6 deletions src/Model/ImportProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ public function run()
]);

$this->consoleOutput->writeln($output);
$this->log->addInfo($output);
$this->log->info($output);

$this->consoleOutput->writeln("<error>$errors</error>");
$this->log->addError($errors);
$this->log->error($errors);

return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
} catch (\Exception $e) {
$this->consoleOutput->writeln($e->getMessage());
$this->log->addCritical($e->getMessage());
$this->log->critical($e->getMessage());
$innerExceptionIterator = $e->getPrevious();
while ($innerExceptionIterator !== null) {
$this->consoleOutput->writeln($innerExceptionIterator->getMessage());
$this->log->addCritical($innerExceptionIterator->getMessage());
$this->log->critical($innerExceptionIterator->getMessage());
$innerExceptionIterator = $innerExceptionIterator->getPrevious();
}

Expand All @@ -131,7 +131,7 @@ private function getItemsMeasured()
{
$this->stopwatch->start('profileinstance');
$this->consoleOutput->writeln('Getting item data');
$this->log->addInfo('Getting item data');
$this->log->info('Getting item data');
$items = $this->getItems();
$stopwatchEvent = $this->stopwatch->stop('profileinstance');

Expand All @@ -148,7 +148,7 @@ private function getItemsMeasured()
]);

$this->consoleOutput->writeln($output);
$this->log->addInfo($output);
$this->log->info($output);

return $items;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/PrintImportLogWhenCliPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function beforeAddLogComment(
) {
$debugData = is_array($debugData) ? implode(', ', $debugData) : $debugData;
$this->consoleOutput->writeln("<info>{$debugData}</info>");
$this->log->addInfo((string)$debugData);
$this->log->info((string)$debugData);
}
}
2 changes: 1 addition & 1 deletion src/RowModifier/AssignAllWebsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("<info>Assigning all products to all websites...</info>");
$this->log->addInfo('Assigning all products to all websites...');
$this->log->info('Assigning all products to all websites...');

$allWebsites = $this->allWebsites();

Expand Down
4 changes: 2 additions & 2 deletions src/RowModifier/AttributeOptionCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function process()
{
$attributes = implode(', ', $this->attributes);
$this->consoleOutput->writeln("<info>Creating attribute options for: {$attributes}</info>");
$this->log->addInfo('Creating attribute options for:'. $attributes);
$this->log->info('Creating attribute options for:'. $attributes);

foreach ($this->attributes as $attribute) {
$this->createForAttribute($attribute);
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function getNonExistingAttributes(string $attribute): array
$this->consoleOutput->writeln(
"<error>AttributeOptionCreator: Invalid value for {$attribute} {$identifier}</error>"
);
$this->log->addError("AttributeOptionCreator: Invalid value for {$attribute} {$identifier}");
$this->log->error("AttributeOptionCreator: Invalid value for {$attribute} {$identifier}");

$item[$attribute] = '';
continue;
Expand Down
8 changes: 4 additions & 4 deletions src/RowModifier/ConfigurableBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("<info>Creating configurable products...</info>");
$this->log->addInfo('Creating configurable products...');
$this->log->info('Creating configurable products...');

$skuCallback = $this->configurableSku;
$attrCallback = $this->attributes;
Expand Down Expand Up @@ -146,7 +146,7 @@ public function process()

$count = count($configurables);
$this->consoleOutput->writeln("{$count} potential configurables created");
$this->log->addInfo("{$count} potential configurables created");
$this->log->info("{$count} potential configurables created");
$configurables = $this->splitOnValue($configurables);

if ($this->enableFilterConfigurable) {
Expand All @@ -165,7 +165,7 @@ public function process()

$count = count($configurables);
$this->consoleOutput->writeln("<info>Created {$count} configurables</info>");
$this->log->addInfo("Created {$count} configurables");
$this->log->info("Created {$count} configurables");

$this->items = array_replace($this->items, $configurables);
}
Expand Down Expand Up @@ -270,7 +270,7 @@ private function splitOnValue($configurables)
$count = count($newConfigurables) - count($configurables);
if ($count > 0) {
$this->consoleOutput->writeln("Created {$count} extra configurables while splitting");
$this->log->addInfo("Created {$count} extra configurables while splitting");
$this->log->info("Created {$count} extra configurables while splitting");
}

return $newConfigurables;
Expand Down
4 changes: 2 additions & 2 deletions src/RowModifier/ExternalCategoryManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("<info>Adding existing product category associations</info>");
$this->log->addInfo('Adding existing product category associations');
$this->log->info('Adding existing product category associations');

$this->initCategoryMapping();
$this->initCategoryProductMapping();
Expand All @@ -85,7 +85,7 @@ public function process()
$categories = array_merge($categories, $this->categoryMapping[$category]);
}
}

if (isset($this->productCategoryMapping[$identifier])) {
$categories = array_merge($categories, $this->productCategoryMapping[$identifier]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RowModifier/ItemMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function validateItem(array $item, $sku)
public function process()
{
$this->consoleOutput->writeln("<info>Mapping item information</info>");
$this->log->addInfo('Mapping item information');
$this->log->info('Mapping item information');

foreach ($this->items as $identifier => $item) {
try {
Expand All @@ -86,7 +86,7 @@ public function process()
$this->consoleOutput->writeln(
"<comment>Value is a object or array for $identifier: {$val}</comment>"
);
$this->log->addInfo("Value is a object or array for $identifier: {$val}");
$this->log->info("Value is a object or array for $identifier: {$val}");

return null;
}
Expand All @@ -97,14 +97,14 @@ public function process()
$output = sprintf('Error validating, skipping %s: %s', $identifier, implode(',', $itemsValidated));

$this->consoleOutput->writeln(sprintf('<comment>%s</comment>', $output));
$this->log->addError($output);
$this->log->error($output);
}

} catch (\Exception $e) {
$this->consoleOutput->writeln(
"<error>ItemMapper: {$e->getMessage()} (removing product {$identifier})</error>"
);
$this->log->addError("ItemMapper: {$e->getMessage()} (removing product {$identifier})");
$this->log->error("ItemMapper: {$e->getMessage()} (removing product {$identifier})");

unset($this->items[$identifier]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/RowModifier/NonUniqueSourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("<info>NonUniqueSourceIterator: Adding information from stream</info>");
$this->log->addInfo('NonUniqueSourceIterator: Adding information from stream');
$this->log->info('NonUniqueSourceIterator: Adding information from stream');

$identifier = $this->identifier;
foreach ($this->iterator as $item) {
Expand All @@ -89,7 +89,7 @@ public function process()
$this->consoleOutput->writeln(
"NonUniqueSourceIterator: <comment>Item not found for {$id}</comment>"
);
$this->log->addInfo("NonUniqueSourceIterator: Item not found for {$id}");
$this->log->info("NonUniqueSourceIterator: Item not found for {$id}");

continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/RowModifier/ProductDisabler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function process()

$count = count($itemsToDisable);
$this->consoleOutput->writeln("<info>ProductDisabler: Disabling {$count} products</info>");
$this->log->addInfo("ProductDisabler: Disabling {$count} products");
$this->log->info("ProductDisabler: Disabling {$count} products");

$this->items += $itemsToDisable;
}
Expand Down
6 changes: 3 additions & 3 deletions src/RowModifier/ProductMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function validateItem(array $item)
public function process()
{
$this->consoleOutput->writeln("<info>Mapping product information</info>");
$this->log->addInfo('Mapping product information');
$this->log->info('Mapping product information');

foreach ($this->getSourceItems() as $item) {
try {
Expand All @@ -53,12 +53,12 @@ public function process()
$output = sprintf('Error validating, skipping %s: %s', $identifier, implode(',', $errors));

$this->consoleOutput->writeln(sprintf('<comment>%s</comment>', $output));
$this->log->addInfo($output);
$this->log->info($output);
}

} catch (\Exception $e) {
$this->consoleOutput->writeln("<error>{$e->getMessage()}</error>");
$this->log->addError($e->getMessage());
$this->log->error($e->getMessage());
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/RowModifier/ProductUrlKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("<info>Checking url_keys and make sure they are unique</info>");
$this->log->addInfo('Checking url_keys and make sure they are unique');
$this->log->info('Checking url_keys and make sure they are unique');

$this->initProductToSku();
foreach ($this->items as $identifier => &$item) {
//check for existence.
if (empty($item['url_key'])) {
$this->consoleOutput->writeln("<comment>ProductUrlKey: url_key not found {$identifier}</comment>");
$this->log->addInfo('ProductUrlKey: url_key not found '.$identifier);
$this->log->info('ProductUrlKey: url_key not found '.$identifier);
}
$item['url_key'] = $this->getUrlKey($item['url_key'], $identifier);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public function getUrlKey($urlKey, $identifier)
$this->consoleOutput->writeln(
"<error>Can not find available URL-key for {$identifier}, you might run into trouble</error>"
);
$this->log->addError("Can not find available URL-key for {$identifier}, you might run into trouble");
$this->log->error("Can not find available URL-key for {$identifier}, you might run into trouble");
}

/**
Expand Down Expand Up @@ -218,4 +218,4 @@ protected function reset()
$this->idToSku = [];
$this->urls = [];
}
}
}
4 changes: 2 additions & 2 deletions src/RowModifier/SourceIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function __construct(
public function process()
{
$this->consoleOutput->writeln("SourceIterator: <info>Adding information from stream</info>");
$this->log->addInfo('SourceIterator: Adding information from stream');
$this->log->info('SourceIterator: Adding information from stream');

$identifier = $this->identifier;
foreach ($this->iterator as $item) {
Expand All @@ -105,7 +105,7 @@ public function process()
$this->consoleOutput->writeln(
"SourceIterator: <comment>Item not found for {$id}</comment>"
);
$this->log->addInfo("SourceIterator: Item not found for {$id}");
$this->log->info("SourceIterator: Item not found for {$id}");

continue 2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/RowModifier/TemplateFieldParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function process()
try {
$item[$fieldName] = $this->filterTemplate->filter($template);
} catch (\Exception $e) {
$this->log->addError($e->getMessage());
$this->log->error($e->getMessage());
$this->messageManager->addExceptionMessage($e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Streamer/FileCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public function getIterator()
$this->consoleOutput->writeln(
"<info>Streamer\FileCsv: Getting data from requestFile {$this->requestFile}</info>"
);
$this->log->addInfo('Streamer\FileCsv: Getting data from requestFile '.$this->requestFile);
$this->log->info('Streamer\FileCsv: Getting data from requestFile '.$this->requestFile);

$requestFile = $this->getRequestFile();
if (! file_exists($requestFile)) {
$this->log->addCritical(sprintf('requestFile %s not found', $requestFile));
$this->log->critical(sprintf('requestFile %s not found', $requestFile));
throw new FileSystemException(__('requestFile %1 not found', $requestFile));
}
$requestFile = fopen($requestFile, 'r');
Expand Down
2 changes: 1 addition & 1 deletion src/Streamer/HttpCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getIterator()
$this->consoleOutput->write(
"<info>Streamer\HttpCsv: Getting data from URL {$this->requestUrl}</info>"
);
$this->log->addInfo('Streamer\HttpCsv: Getting data from URL '.$this->requestUrl);
$this->log->info('Streamer\HttpCsv: Getting data from URL '.$this->requestUrl);

$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(new \Kevinrob\GuzzleCache\CacheMiddleware(
Expand Down

0 comments on commit 0145aab

Please sign in to comment.