Skip to content

๐Ÿงพ 10. Logging & Error Handling โ€‹

Logging โ€‹

php
fst_log('INFO', 'Pembayaran berhasil.', ['invoice' => 'INV-001']);
fst_log('ERROR', 'Koneksi gagal.', ['endpoint' => $url]);

Log ditulis ke file .fst.log dalam format JSON per baris.

Error Handler Kustom โ€‹

Daftarkan callback untuk mengirim notifikasi (Telegram, Slack, dll) saat error terjadi:

php
// Letakkan di globals/error_handler.php
fst_error_handler(function(Throwable $e) {
    $msg = $e->getMessage();
    // send_telegram_alert("๐Ÿšจ ERROR: $msg");
});

Mode Production vs Development โ€‹

AspekDevelopmentProduction
Error displayStack trace visual di browserPesan generik, detail di .fst.log
Cache viewRe-compile jika file berubahLangsung dimuat tanpa cek
Cache routerRe-scan jika folder app/ berubahTerkunci, tidak pernah re-scan

Dibuat dengan โค๏ธ untuk ekosistem PHP yang lebih sederhana.