Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Provider/Chain/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Geocoder\Provider\Provider;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LogLevel;

/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
Expand All @@ -27,6 +28,16 @@ final class Chain implements Provider, LoggerAwareInterface
{
use LoggerAwareTrait;

/**
* @var string
*/
private $geocodeQueryLogLevel = LogLevel::ALERT;

/**
* @var string
*/
private $reverseQueryLogLevel = LogLevel::ALERT;

/**
* @var Provider[]
*/
Expand All @@ -40,6 +51,16 @@ public function __construct(array $providers = [])
$this->providers = $providers;
}

public function setGeocodeQueryLogLevel(string $level)
{
$this->geocodeQueryLogLevel = $level;
}

public function setReverseQueryLogLevel(string $level)
{
$this->reverseQueryLogLevel = $level;
}

/**
* {@inheritdoc}
*/
Expand All @@ -54,7 +75,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection
}
} catch (\Throwable $e) {
$this->log(
'alert',
$this->geocodeQueryLogLevel,
'Provider "{providerName}" could not geocode address: "{address}".',
[
'exception' => $e,
Expand Down Expand Up @@ -83,7 +104,7 @@ public function reverseQuery(ReverseQuery $query): Collection
} catch (\Throwable $e) {
$coordinates = $query->getCoordinates();
$this->log(
'alert',
$this->reverseQueryLogLevel,
sprintf('Provider "%s" could reverse coordinates: %f, %f.', $provider->getName(), $coordinates->getLatitude(), $coordinates->getLongitude()),
['exception' => $e]
);
Expand Down