Services
LoggerServiceInterface
v1.0.0Structured event logging. This is the only required non-nullable service in SdkContext.
Access
$ctx->logger()->info('reports.boot', []);How To Use It
- Use structured events for operational visibility instead of ad hoc echo, print_r, or scattered error_log calls.
- Because logger() is always non-null on SdkContext, it is the safest cross-cutting service to use inside lifecycle hooks and failure paths.
Works Well With
Methods
public function info(string $event, array $context = []): voidLogs an informational event.
public function warn(string $event, array $context = []): voidLogs a warning event.
public function error(string $event, array $context = []): voidLogs an error event.
public function debug(string $event, array $context = []): voidLogs a verbose debugging event.
Example
bootstrap.php
public function handleSyncFailure(SdkContext $ctx, Throwable $e): void
{
$ctx->logger()->error('reports.sync_failed', [
'message' => $e->getMessage(),
'module' => $this->getSlug(),
]);
}