mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
909 stars 187 forks source link

Can't cache configuration when using logObject #121

Closed apokryfos closed 3 years ago

apokryfos commented 3 years ago

I am trying to cache my configuration while also using the default laravel logger in Laravel 8

I would like to just use the same logger I use normally and also cache my configuration.

Not sure I'm missing something here. Is it meant to be possible to cache the configuration when doing this? Is there an alternative?

cviebrock commented 3 years ago

You can't serialize that value. I believe you would need to make a class with a method that returns that value ... something like:

class Foo
    function getLogObject() {
        return (new \Illuminate\Log\LogManager(app()))->driver()->getLogger();
    }
}

and then pass that in your config as a callable:

'logObject' => [Foo:class, 'getLogObject'],
cviebrock commented 3 years ago

Closing due to no response. Feel free to re-open or comment if you are still having issues.