---
title: "Events & logging — Google Places for Laravel | Roundly"
description: "One lifecycle event per request sent to Google and opt-in request logging — for metrics, alerting and audits, without ever exposing the key."
url: https://roundly-consulting.com/open-source/docs/google-places-for-laravel/events-logging
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Google Places for Laravel](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)

# Events & logging

Every request the client sends to Google dispatches exactly one lifecycle event you can listen to for logging, metrics or alerting: PlacesResponseReceived for an answer, PlacesRequestFailed for an error or an unreachable API. Neither event carries the API key:

```php
use RoundlyConsulting\GooglePlaces\Events\PlacesRequestFailed;
use RoundlyConsulting\GooglePlaces\Events\PlacesResponseReceived;

// PlacesResponseReceived: endpoint, httpStatus, googleStatus, durationMs
// PlacesRequestFailed:    endpoint, httpStatus, googleStatus, message
```

| Event | Properties | Dispatched |
| --- | --- | --- |
| `PlacesResponseReceived` | endpoint, httpStatus, googleStatus, durationMs | After every answered call — including a details 404 and a geocoding ZERO\_RESULTS. |
| `PlacesRequestFailed` | endpoint, httpStatus, googleStatus, message | When Google returns an error or cannot be reached; httpStatus is 0 for a connection failure. |

endpoint is one of details, autocomplete, textSearch (also for findPlace() and each paginated page), nearbySearch, geocode, geocodeAddress, distance, computeMatrix, photoUri or photoContents (also for photo()->url(), contents() and save()). googleStatus is Google’s own status string when the response carries one; a failure’s message is redacted. A call that sends nothing dispatches nothing: a cache hit, photoUrl() (built locally), and a call refused before sending — no key configured, or a client-side rate-limit fail-fast (RateLimitExceededException). check() reports through its return value instead, so its probes dispatch no events either.

## Listening

```php
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use RoundlyConsulting\GooglePlaces\Events\PlacesRequestFailed;
use RoundlyConsulting\GooglePlaces\Events\PlacesResponseReceived;

// e.g. in AppServiceProvider::boot()
Event::listen(function (PlacesResponseReceived $event): void {
    if ($event->durationMs > 2000) {
        Log::warning('Slow Google call', ['endpoint' => $event->endpoint, 'ms' => $event->durationMs]);
    }
});

Event::listen(function (PlacesRequestFailed $event): void {
    if ($event->googleStatus === 'PERMISSION_DENIED') {
        Log::critical('Google API key rejected', ['endpoint' => $event->endpoint, 'message' => $event->message]);
    }
});
```

## Request logging

Opt-in logging of every request is built on the same events. Responses are logged at info level, failures at warning level, with endpoint, HTTP status, Google status and duration or message. The API key is never logged — a failure’s message is redacted as described under Error handling:

```bash
GOOGLE_PLACES_LOGGING=true
GOOGLE_PLACES_LOG_CHANNEL=stack   # optional; defaults to the app's default channel
```

Laravel’s own HTTP client events, and tools that record them such as Telescope, see each request as sent — a Geocoding request URL includes the key. That recording happens in your app, outside this package; filter it there.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)
