Skip to content

Commit

Permalink
Sync release-2.0.5 from other repository
Browse files Browse the repository at this point in the history
Added better logging that at least allows to see the plugin that failed. https://www.wrike.com/open.htm?id=1196808267
  • Loading branch information
TobiasGraml11 committed Nov 8, 2023
1 parent 23a49b3 commit a407459
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Async/JobExecutionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handle(JobMessageInterface $message): void
} catch (\Throwable $e) {
// Should not trigger any exceptions to avoid message requeue
$this->logger->error(
\sprintf('Failed to run job[id: %s] message: %s', $message->getJobId(), $e->getMessage()),
\sprintf('Failed to run job[id: %s] | ' . get_class($message) . ' | message: %s', $message->getJobId(), $e->getMessage()),
);
}
}
Expand Down
19 changes: 16 additions & 3 deletions src/NostoScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,29 @@

use Shopware\Core\Framework\Bundle;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\{XmlFileLoader};
use Symfony\Component\DependencyInjection\Loader\{DirectoryLoader, GlobFileLoader, XmlFileLoader, YamlFileLoader};

class NostoScheduler extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Resources/config'));
$loader->load('services.xml');
$locator = new FileLocator('Resources/config');

$resolver = new LoaderResolver([
new YamlFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
]);

$configLoader = new DelegatingLoader($resolver);

$confDir = \rtrim($this->getPath(), '/') . '/Resources/config';

$configLoader->load($confDir . '/{packages}/*.yaml', 'glob');
}
}
9 changes: 9 additions & 0 deletions src/Resources/config/packages/monolog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
monolog:
channels: ['nosto_scheduler']

handlers:
myPluginLogHandler:
type: rotating_file
path: "%kernel.logs_dir%/nosto_scheduler_%kernel.environment%.log"
level: error
channels: [ "nosto_scheduler" ]
2 changes: 1 addition & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!-- Job Management Services -->
<service id="Nosto\Scheduler\Async\JobExecutionHandler">
<argument type="service" id="logger"/>
<argument type="service" id="monolog.logger.nosto_scheduler" />
<argument type="service" id="Nosto\Scheduler\Model\Job\JobRunner"/>
<tag name="messenger.message_handler"/>
</service>
Expand Down

0 comments on commit a407459

Please sign in to comment.