diff --git a/README.md b/README.md index 50a6dae..5a55ff7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,29 @@ You can install the package via composer: composer require bilfeldt/laravel-http-client-logger ``` -Optionally publish the config file with: +### Laravel + +This package makes use of [Laravels package auto-discovery mechanism](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518) so **there is no need to do any futher steps** - skip directly to the [usage](#usage) section below. If for some reason you wish to opt-out of package auto discovery, check [the Laravel Docs](https://laravel.com/docs/8.x/packages#opting-out-of-package-discovery) for more details. + +### Lumen + +NOTE: Lumen is **not** officially supported by this package. However, we are currently not aware of any incompatibilities. + +If you use Lumen register the service provider in `bootstrap/app.php` like so: + +```php +register(Bilfeldt\LaravelHttpClientLogger\LaravelHttpClientLoggerServiceProvider::class); + +// If you want to use the Facades provided by the package +$app->withFacades(); +``` + +### Config + +Optionally in Laravel publish the config file with: ```bash php artisan vendor:publish --provider="Bilfeldt\LaravelHttpClientLogger\LaravelHttpClientLoggerServiceProvider" --tag="laravel-http-client-logger-config" ``` diff --git a/src/HttpLogger.php b/src/HttpLogger.php index 0042f77..8c4f1a9 100644 --- a/src/HttpLogger.php +++ b/src/HttpLogger.php @@ -3,6 +3,7 @@ namespace Bilfeldt\LaravelHttpClientLogger; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Date; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; @@ -54,7 +55,7 @@ protected function getReplace(): array protected function getFileName(): string { - return (Arr::get($this->config, 'prefix_timestamp') ? now()->format(Arr::get($this->config, 'prefix_timestamp')) : '') + return (Arr::get($this->config, 'prefix_timestamp') ? Date::now()->format(Arr::get($this->config, 'prefix_timestamp')) : '') .Arr::get($this->config, 'filename'); } diff --git a/src/LaravelHttpClientLoggerServiceProvider.php b/src/LaravelHttpClientLoggerServiceProvider.php index e0d4a41..31ad0cf 100644 --- a/src/LaravelHttpClientLoggerServiceProvider.php +++ b/src/LaravelHttpClientLoggerServiceProvider.php @@ -38,8 +38,8 @@ public function packageBooted() ) { /** @var \Illuminate\Http\Client\PendingRequest $this */ return $this->withMiddleware((new LoggingMiddleware( - $logger ?? resolve(HttpLoggerInterface::class), - $filter ?? resolve(HttpLoggingFilterInterface::class) + $logger ?? app(HttpLoggerInterface::class), + $filter ?? app(HttpLoggingFilterInterface::class) ))->__invoke($context, $config)); });