- config/logging.php: Themen-Channels billing, ki, monitoring, market als daily-Dateien mit gemeinsamer Aufbewahrung (LOG_DAILY_DAYS), Stack-Default auf daily; Channel `testing` für die Suite. - Fachliche Log-Aufrufe in Billing, KI-Jobs, OperationalAlert und Kursdaten auf Log::channel() umgestellt. - phpunit.xml + TestCase: Suite schreibt ausschließlich nach testing-YYYY-MM-DD.log; LogChannelsTest sichert die Konfiguration. - docs/weiteres: Decision-Update Duplicate-Content entfernt (überholt durch Roadmap-Anhang 2), Decision-Update Verlinkung & Backlinks als Referenz wieder abgelegt, README-Index nachgezogen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Mail\OperationalAlertMail;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Throwable;
|
|
|
|
/**
|
|
* Zentrale Betriebs-Alerts (R5.3): meldet fehlgeschlagene Scheduler-Tasks und
|
|
* Queue-Jobs. Der Log-Eintrag (`critical`) ist die verlässliche Ebene und läuft
|
|
* immer; die Mail ist Best-Effort und darf den auslösenden Prozess nie mit in
|
|
* den Abgrund reißen (Mailserver down o. ä.).
|
|
*/
|
|
class OperationalAlert
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $context
|
|
*/
|
|
public static function send(string $summary, array $context = []): void
|
|
{
|
|
Log::channel('monitoring')->critical('[monitoring] '.$summary, $context);
|
|
|
|
if (! config('monitoring.alerts.enabled')) {
|
|
return;
|
|
}
|
|
|
|
$recipient = config('monitoring.alerts.mail_to');
|
|
|
|
if (empty($recipient)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
Mail::to($recipient)->send(new OperationalAlertMail($summary, $context));
|
|
} catch (Throwable $e) {
|
|
Log::channel('monitoring')->error('[monitoring] Alert-Mail konnte nicht versendet werden.', [
|
|
'summary' => $summary,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
}
|
|
}
|
|
}
|