Services

LoggerServiceInterface

v1.0.0

Structured 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.

Methods

public function info(string $event, array $context = []): void

Logs an informational event.

public function warn(string $event, array $context = []): void

Logs a warning event.

public function error(string $event, array $context = []): void

Logs an error event.

public function debug(string $event, array $context = []): void

Logs 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(),
    ]);
}