Logging & Error Handling (FestiUtils)

FestiUtils is a static utility class that provides logging helpers and centralised exception handling for the framework. Two extension points — log interceptors and exception handlers — let application code hook into these pipelines without modifying core files.

Log Interceptors

Log interceptors are callbacks that run after the default log entry has been written to disk. Use them to forward log messages to external services, push entries to a queue, send to a monitoring system, etc.

Register a log interceptor

FestiUtils::addLogInterceptor(
    function(mixed $msg, string $type, string $body): void {
        MyMonitoring::send($msg, $type, $body);
    }
);

Exception Handlers

Exception handlers are callbacks that run before the default core exception handling. Return true from a handler to suppress the default behaviour (log write + optional email); return false to let the default handling proceed.

Register an exception handler

FestiUtils::addExceptionHandler(
    function(Throwable $exception, string $type, bool $isEmail): bool {
        if ($exception instanceof MyKnownException) {
            return true;
        }
        return false;
    }
);

Clearing callbacks (testing)

To reset all registered interceptors and handlers — typically in test teardown:

FestiUtils::clearLogCallbacks();