feature/logging_Service #22
@ -7,7 +7,6 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
use App\Services\Ldap\LdapAuthService;
|
use App\Services\Ldap\LdapAuthService;
|
||||||
use App\Services\Logging\LoggingService;
|
use App\Services\Logging\LoggingService;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zuständig für alles rund um den Login:
|
* Zuständig für alles rund um den Login:
|
||||||
@ -93,7 +92,7 @@ class AuthController
|
|||||||
// true = Authentifizierung erfolgreich
|
// true = Authentifizierung erfolgreich
|
||||||
// false = Anmeldedaten fachlich ungültig (Benutzer/Passwort falsch)
|
// false = Anmeldedaten fachlich ungültig (Benutzer/Passwort falsch)
|
||||||
$authenticated = $this->ldapAuthService->authenticate($username, $password);
|
$authenticated = $this->ldapAuthService->authenticate($username, $password);
|
||||||
} catch (Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
// HIER ist vorher dein Fehler entstanden:
|
// HIER ist vorher dein Fehler entstanden:
|
||||||
// - showLoginForm() wurde nur aufgerufen, das Ergebnis aber ignoriert
|
// - showLoginForm() wurde nur aufgerufen, das Ergebnis aber ignoriert
|
||||||
// - danach kam ein "return;" ohne Rückgabewert → Rückgabetyp array wurde verletzt
|
// - danach kam ein "return;" ohne Rückgabewert → Rückgabetyp array wurde verletzt
|
||||||
|
|||||||
@ -7,7 +7,6 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
use App\Services\Ldap\LdapDirectoryService;
|
use App\Services\Ldap\LdapDirectoryService;
|
||||||
use App\Services\Logging\LoggingService;
|
use App\Services\Logging\LoggingService;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller für die Benutzer- und Gruppenanzeige.
|
* Controller für die Benutzer- und Gruppenanzeige.
|
||||||
@ -70,7 +69,7 @@ class UserManagementController
|
|||||||
// Benutzer- und Gruppenlisten aus dem AD laden.
|
// Benutzer- und Gruppenlisten aus dem AD laden.
|
||||||
$users = $this->directoryService->getUsers();
|
$users = $this->directoryService->getUsers();
|
||||||
$groups = $this->directoryService->getGroups();
|
$groups = $this->directoryService->getGroups();
|
||||||
} catch (Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
// Technische Details ins Log, für den Benutzer eine allgemeine Meldung.
|
// Technische Details ins Log, für den Benutzer eine allgemeine Meldung.
|
||||||
$this->logger->logException(
|
$this->logger->logException(
|
||||||
'Fehler beim Laden von Benutzern/Gruppen.',
|
'Fehler beim Laden von Benutzern/Gruppen.',
|
||||||
|
|||||||
@ -6,7 +6,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Services\Logging;
|
namespace App\Services\Logging;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Einfacher File-Logger für die AdminTool-Anwendung.
|
* Einfacher File-Logger für die AdminTool-Anwendung.
|
||||||
@ -31,7 +30,7 @@ class LoggingService
|
|||||||
*
|
*
|
||||||
* @var array<string, int>
|
* @var array<string, int>
|
||||||
*/
|
*/
|
||||||
private const array LEVEL_MAP = [
|
private const LEVEL_MAP = [
|
||||||
'debug' => 100,
|
'debug' => 100,
|
||||||
'info' => 200,
|
'info' => 200,
|
||||||
'warning' => 300,
|
'warning' => 300,
|
||||||
@ -87,7 +86,7 @@ class LoggingService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timestamp = new DateTimeImmutable()->format('Y-m-d H:i:s');
|
$timestamp = (new DateTimeImmutable())->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
$contextJson = $context === []
|
$contextJson = $context === []
|
||||||
? '{}'
|
? '{}'
|
||||||
@ -114,10 +113,10 @@ class LoggingService
|
|||||||
* Komfortmethode, um Exceptions strukturiert zu loggen.
|
* Komfortmethode, um Exceptions strukturiert zu loggen.
|
||||||
*
|
*
|
||||||
* @param string $message Kurzer Kontexttext zur Exception
|
* @param string $message Kurzer Kontexttext zur Exception
|
||||||
* @param Throwable $exception Die geworfene Exception
|
* @param \Throwable $exception Die geworfene Exception
|
||||||
* @param array<string, mixed> $context Zusätzlicher Kontext (Route, Benutzername, Remote-IP, ...)
|
* @param array<string, mixed> $context Zusätzlicher Kontext (Route, Benutzername, Remote-IP, ...)
|
||||||
*/
|
*/
|
||||||
public function logException(string $message, Throwable $exception, array $context = []): void
|
public function logException(string $message, \Throwable $exception, array $context = []): void
|
||||||
{
|
{
|
||||||
$exceptionContext = [
|
$exceptionContext = [
|
||||||
'exception_class' => get_class($exception),
|
'exception_class' => get_class($exception),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user