19
19
use Geocoder \Provider \Provider ;
20
20
use Psr \Log \LoggerAwareInterface ;
21
21
use Psr \Log \LoggerAwareTrait ;
22
+ use Psr \Log \LogLevel ;
22
23
23
24
/**
24
25
* @author Markus Bachmann <[email protected] >
@@ -27,6 +28,16 @@ final class Chain implements Provider, LoggerAwareInterface
27
28
{
28
29
use LoggerAwareTrait;
29
30
31
+ /**
32
+ * @var string
33
+ */
34
+ private $ geocodeQueryLogLevel = LogLevel::ALERT ;
35
+
36
+ /**
37
+ * @var string
38
+ */
39
+ private $ reverseQueryLogLevel = LogLevel::ALERT ;
40
+
30
41
/**
31
42
* @var Provider[]
32
43
*/
@@ -40,6 +51,16 @@ public function __construct(array $providers = [])
40
51
$ this ->providers = $ providers ;
41
52
}
42
53
54
+ public function setGeocodeQueryLogLevel (string $ level )
55
+ {
56
+ $ this ->geocodeQueryLogLevel = $ level ;
57
+ }
58
+
59
+ public function setReverseQueryLogLevel (string $ level )
60
+ {
61
+ $ this ->reverseQueryLogLevel = $ level ;
62
+ }
63
+
43
64
/**
44
65
* {@inheritdoc}
45
66
*/
@@ -54,7 +75,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection
54
75
}
55
76
} catch (\Throwable $ e ) {
56
77
$ this ->log (
57
- ' alert ' ,
78
+ $ this -> geocodeQueryLogLevel ,
58
79
'Provider "{providerName}" could not geocode address: "{address}". ' ,
59
80
[
60
81
'exception ' => $ e ,
@@ -83,7 +104,7 @@ public function reverseQuery(ReverseQuery $query): Collection
83
104
} catch (\Throwable $ e ) {
84
105
$ coordinates = $ query ->getCoordinates ();
85
106
$ this ->log (
86
- ' alert ' ,
107
+ $ this -> reverseQueryLogLevel ,
87
108
sprintf ('Provider "%s" could reverse coordinates: %f, %f. ' , $ provider ->getName (), $ coordinates ->getLatitude (), $ coordinates ->getLongitude ()),
88
109
['exception ' => $ e ]
89
110
);
0 commit comments