`) und empfangene (`<`) Nachricht an * ihren Logger – unabhängig davon, ob das Debug-Log an ist. Dieser Logger * sammelt alles im Speicher und reicht es zusätzlich an das Debug-Log weiter. * Was ankommt, hat die Bibliothek bereits von PIN und Benutzerkennung befreit * (`SanitizingLogger`). */ class BankProtokollLogger extends AbstractLogger { /** @var list */ private array $zeilen = []; private DebugLogAdapter $debug; public function __construct() { $this->debug = new DebugLogAdapter(); } /** * @param mixed $level * @param array $context */ public function log($level, string|Stringable $message, array $context = []): void { $this->debug->log($level, $message, $context); $this->vermerke('[' . (is_scalar($level) ? (string)$level : 'info') . '] ' . (string)$message); } /** Eine eigene Zeile (etwa ein Schritt der Anwendung) ins Protokoll. */ public function vermerke(string $zeile): void { $this->zeilen[] = date('Y-m-d H:i:s') . ' ' . self::alsUtf8($zeile); } public function text(): string { return implode("\n", $this->zeilen); } /** * Die Wire-Nachrichten kommen in ISO-8859-1; die Datenbank nimmt nur * gültiges UTF-8. */ private static function alsUtf8(string $text): string { return mb_check_encoding($text, 'UTF-8') ? $text : mb_convert_encoding($text, 'UTF-8', 'ISO-8859-1'); } }