geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.95k stars 517 forks source link

How to use the logger #901

Closed simonschaufi closed 5 years ago

simonschaufi commented 5 years ago

Hi, I'm using your package with a proxy package https://github.com/geocoder-php/GeocoderLaravel.

I would like to log the Exception thrown here:

https://github.com/geocoder-php/Geocoder/blob/1bd7d59a6725586158d4aae121c23195334cf842/src/Provider/Chain/Chain.php#L123-L128

but I have no clue how to inject a logger. I also didn't find anything in the documentation. Could you please help?

eugenekurasov commented 5 years ago

LoggerAwareTrait have method setLogger

If you use DI from symfony yo can see example how use setters.

If you don't use any framework here example with Monolog\Logger

$logger = new Monolog\Logger();
// Setup handler fro logger

$chain = new \Geocoder\Provider\Chain\Chain([
    // ...
]);

$chain->setLogger($logger);
atymic commented 5 years ago

@simonschaufi Did you get this solved?

atymic commented 5 years ago

@jbelien I think this can be closed now :)