virtua/shopware-app-logger-bundle

Add basic logger for Shopware application

Installs: 94

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 1

Open Issues: 0

Type:symfony-bundle

1.0.4 2022-07-05 13:19 UTC

This package is auto-updated.

Last update: 2024-11-06 11:57:22 UTC


README

Description

This bundle contains fully functional logger for Shopware Applications.

Requirements

  • PHP >= 8.0
  • Symfony 6
  • ShopwareShop Entity

Installation

  • Add bundle repository to composer.json
"virtua/shopware-app-logger-bundle": "^1.0"
  • Add bundle to bundles.php
Virtua\ShopwareAppLoggerBundle\VirtuaShopwareAppLoggerBundle::class => ['all' => true]
  • Add bundle routes to routes.yaml
shopware_app_logger_bundle_routes:
    resource: "@VirtuaShopwareAppLoggerBundle/Resources/config/routes.yaml"
  • Create new file config/packages/virtua_shopware_app_logger.yaml, with data:
imports:
    - { resource: '@VirtuaShopwareAppLoggerBundle/Resources/config/config.yml' }
  • Run migrations bin/console doctrine:migrations:migrate

Usage

#####Writing This bundle is fully functional right after installation. To create new log, use log() method from Logger service. As a paremeter you have to provide LoggerData object, which can be found in Util directory.

Example log() usage:

use Virtua\ShopwareAppLoggerBundle\Service\Logger;
use Virtua\ShopwareAppLoggerBundle\Util\LoggerData;

/* ... */

public function __construct(Logger $logger)
{
	$this->logger = $logger;
}

/* ... */

public function exampleFunction(): void
{
	$loggerData = new LoggerData($shopId);
	$loggerData->setErrorMessage("Your error message");
	$loggerData->setErrorCode(404);   //This is optional, default code is 400
	$this->logger->log($loggerData);
}

#####Reading Logs are displayed in /logs/list/{shopId} route, implemented in AppLoggerController To add this into menu in your Shopware, you need to add new module in your app manifest.

Example module in manifest.xml:

<module name="logsModule"
    source="https://your_app_url/logs/list"
    parent="sw-extension"
    position="50"
>
    <label>Logs</label>
    <label lang="de-DE">Logs</label>
    <label lang="pl-PL">Logi</label>
</module>
```layed in **/logs/list/{shopId}** route, implemented in **AppLoggerController**