1. Go to this page and download the library: Download muckiware/log-plugin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muckiware / log-plugin example snippets
declare(strict_types=1);
namespace YourPlugin\Storefront\Pagelet\Header\Subscriber;
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Struct\ArrayEntity;
use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Psr\Log\LoggerInterface;
/**
* Class YourHeaderPageSubscriber
*/
class YourHeaderPageSubscriber implements EventSubscriberInterface
{
public function __construct(
...
protected LoggerInterface $logger
) {
...
$this->logger = $logger;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
// Subscribing to HeaderPageLetLoadedEvent
HeaderPageletLoadedEvent::class => 'HeaderPageletLoadedEvent',
];
}
/**
* @param HeaderPageletLoadedEvent $event
*/
public function HeaderPageletLoadedEvent(HeaderPageletLoadedEvent $event): void
{
$this->logger->debug('Call HeaderPageEvent', array('myplugin', 'vendor'));
...
$this->logger->info('debug', 'Call HeaderPageEvent', array('myplugin', 'vendor'));
}
}