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