feat: extended logging
This commit is contained in:
@@ -2,20 +2,26 @@ monolog:
|
||||
channels:
|
||||
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
|
||||
- bpn
|
||||
- core
|
||||
|
||||
when@dev:
|
||||
monolog:
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
channels: ["!event"]
|
||||
bpn:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.bpn.log"
|
||||
level: debug
|
||||
channels: ["bpn"]
|
||||
core:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.core.log"
|
||||
level: debug
|
||||
channels: ["core"]
|
||||
main:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
channels: ["!event"]
|
||||
# uncomment to get logging in your browser
|
||||
# you may have to allow bigger header sizes in your Web server configuration
|
||||
#firephp:
|
||||
@@ -46,17 +52,24 @@ when@test:
|
||||
when@prod:
|
||||
monolog:
|
||||
handlers:
|
||||
bpn:
|
||||
type: rotating_file
|
||||
max_files: 7
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.bpn.log"
|
||||
level: info
|
||||
channels: ["bpn"]
|
||||
core:
|
||||
type: rotating_file
|
||||
max_files: 7
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.core.log"
|
||||
level: info
|
||||
channels: ["core"]
|
||||
main:
|
||||
type: fingers_crossed
|
||||
action_level: error
|
||||
handler: nested
|
||||
excluded_http_codes: [404, 405]
|
||||
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
|
||||
bpn:
|
||||
type: stream
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.bpn.log"
|
||||
level: debug
|
||||
channels: ["bpn"]
|
||||
nested:
|
||||
type: stream
|
||||
path: php://stderr
|
||||
|
||||
@@ -12,6 +12,7 @@ services:
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
bind:
|
||||
$xmlPath: '%kernel.project_dir%/var/xmlexport'
|
||||
$logger: '@monolog.logger.core'
|
||||
|
||||
# makes classes in src/ available to be used as services
|
||||
# this creates a service per class whose id is the fully-qualified class name
|
||||
|
||||
@@ -34,9 +34,9 @@ class ApiClient
|
||||
|
||||
public function __construct(
|
||||
private readonly SerializerInterface $serializer,
|
||||
private readonly ApiResponseParser $responseParser,
|
||||
private readonly LoggerInterface $logger,
|
||||
array $options
|
||||
private readonly ApiResponseParser $responseParser,
|
||||
private readonly LoggerInterface $logger,
|
||||
array $options
|
||||
) {
|
||||
$this->config = $this->resolveOptions($options);
|
||||
}
|
||||
@@ -296,6 +296,9 @@ class ApiClient
|
||||
])
|
||||
;
|
||||
|
||||
$this->logger->info('Sending request to BPN API', [
|
||||
'requestId' => $requestId,
|
||||
]);
|
||||
|
||||
if (true === $this->config['debug']) {
|
||||
$this->dumpXmlToFile('request', $requestId, $body);
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\BusProNet\Security;
|
||||
use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\BusProNet\Model\CrmAttributes;
|
||||
use App\BusProNet\Model\CrmAttributesResponse;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Controller\Booking;
|
||||
|
||||
use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -19,6 +20,7 @@ class DownloadController extends AbstractController
|
||||
public function __construct(
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly Security $security,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -48,6 +50,12 @@ class DownloadController extends AbstractController
|
||||
'confirmation' => 'Vorgangdruck',
|
||||
};
|
||||
|
||||
$this->logger->info('Initiated document download', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'document_type' => $fileType,
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
|
||||
$file = $this
|
||||
->apiClient
|
||||
->getDocuments($bpnUser->getEmail(), $bpnUser->getPassword(), $id, $type)
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Form\BookingType;
|
||||
use App\Form\Model\BookingData;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -20,11 +21,12 @@ use Symfony\Contracts\Cache\ItemInterface;
|
||||
class EditController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly TravelLoader $travelDataLoader,
|
||||
private readonly PickupLoader $pickupDataLoader,
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly TravelLoader $travelDataLoader,
|
||||
private readonly PickupLoader $pickupDataLoader,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly Security $security,
|
||||
private readonly Security $security,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -87,9 +89,17 @@ class EditController extends AbstractController
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$response = $this->apiClient->updateBooking($formData);
|
||||
|
||||
$this->logger->info('Initiated booking update', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
if (false === $response->isSuccessful()) {
|
||||
$this->addFlash('error', $response->message);
|
||||
$this->logger->error('Error initiating booking update', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
'message' => $response->message,
|
||||
]);
|
||||
} else {
|
||||
try {
|
||||
$this->cache->delete($cacheKey);
|
||||
@@ -98,6 +108,11 @@ class EditController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Buchung erfolgreich aktualisiert');
|
||||
|
||||
$this->logger->info('Booking update successful', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Controller;
|
||||
use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\Form\PersonalDataType;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -14,8 +15,12 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class PersonalDataController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ApiClient $apiClient, private readonly Security $security)
|
||||
{}
|
||||
public function __construct(
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly Security $security,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/personal-data', name: 'app_personal_data')]
|
||||
#[IsGranted('ROLE_USER')]
|
||||
@@ -41,6 +46,9 @@ class PersonalDataController extends AbstractController
|
||||
try {
|
||||
$this->apiClient->updatePersonalData($bpnUser->getEmail(), $bpnUser->getPassword(), $personalData);
|
||||
$this->addFlash('success', 'Deine persönlichen Daten wurden aktualisiert');
|
||||
$this->logger->info('Updated personal data', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
]);
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
}
|
||||
@@ -74,6 +82,9 @@ class PersonalDataController extends AbstractController
|
||||
try {
|
||||
$this->apiClient->updateNewsletterRegistration($bpnUser->getEmail(), $bpnUser->getPassword(), $personalData);
|
||||
$this->addFlash('success', 'Deine Anmeldung zum Newsletter wurde aktualisiert');
|
||||
$this->logger->info('Updated newsletter registration', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
]);
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\Form\Model\RegistrationData;
|
||||
use App\Form\RegistrationType;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -14,8 +15,10 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class RegistrationController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ApiClient $apiClient)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/registration', name: 'app_registration')]
|
||||
@@ -36,8 +39,15 @@ class RegistrationController extends AbstractController
|
||||
} else {
|
||||
$this->addFlash('error', 'Möglicherweise bist du bereits registriert. Bitte setze dein Passwort zurück.');
|
||||
}
|
||||
$this->logger->info('Initiated registration', [
|
||||
'email' => $registrationData->email,
|
||||
]);
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
$this->logger->error('Error initiating registration', [
|
||||
'email' => $registrationData->email,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_login');
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -15,7 +16,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class ResetPasswordController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ApiClient $apiClient)
|
||||
public function __construct(private readonly ApiClient $apiClient, private readonly LoggerInterface $logger)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,8 +48,15 @@ class ResetPasswordController extends AbstractController
|
||||
try {
|
||||
$this->apiClient->resetPassword($form->get('email')->getData());
|
||||
$this->addFlash('success', 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.');
|
||||
$this->logger->info('Initiated password reset', [
|
||||
'email' => $form->get('email')->getData(),
|
||||
]);
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
$this->logger->error('Error initiating password reset', [
|
||||
'email' => $form->get('email')->getData(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_login');
|
||||
|
||||
Reference in New Issue
Block a user