Skip to content

Commit fe9de55

Browse files
authored
Merge pull request #10 from gpibarra/lumen
Lumen compatibility
2 parents bc1eded + f32074d commit fe9de55

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,29 @@ You can install the package via composer:
1818
composer require bilfeldt/laravel-http-client-logger
1919
```
2020

21-
Optionally publish the config file with:
21+
### Laravel
22+
23+
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.
24+
25+
### Lumen
26+
27+
NOTE: Lumen is **not** officially supported by this package. However, we are currently not aware of any incompatibilities.
28+
29+
If you use Lumen register the service provider in `bootstrap/app.php` like so:
30+
31+
```php
32+
<?php
33+
// bootstrap/app.php
34+
35+
$app->register(Bilfeldt\LaravelHttpClientLogger\LaravelHttpClientLoggerServiceProvider::class);
36+
37+
// If you want to use the Facades provided by the package
38+
$app->withFacades();
39+
```
40+
41+
### Config
42+
43+
Optionally in Laravel publish the config file with:
2244
```bash
2345
php artisan vendor:publish --provider="Bilfeldt\LaravelHttpClientLogger\LaravelHttpClientLoggerServiceProvider" --tag="laravel-http-client-logger-config"
2446
```

src/HttpLogger.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Bilfeldt\LaravelHttpClientLogger;
44

55
use Illuminate\Support\Arr;
6+
use Illuminate\Support\Facades\Date;
67
use Illuminate\Support\Facades\Log;
78
use Illuminate\Support\Facades\Storage;
89
use Illuminate\Support\Str;
@@ -54,7 +55,7 @@ protected function getReplace(): array
5455

5556
protected function getFileName(): string
5657
{
57-
return (Arr::get($this->config, 'prefix_timestamp') ? now()->format(Arr::get($this->config, 'prefix_timestamp')) : '')
58+
return (Arr::get($this->config, 'prefix_timestamp') ? Date::now()->format(Arr::get($this->config, 'prefix_timestamp')) : '')
5859
.Arr::get($this->config, 'filename');
5960
}
6061

src/LaravelHttpClientLoggerServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function packageBooted()
3838
) {
3939
/** @var \Illuminate\Http\Client\PendingRequest $this */
4040
return $this->withMiddleware((new LoggingMiddleware(
41-
$logger ?? resolve(HttpLoggerInterface::class),
42-
$filter ?? resolve(HttpLoggingFilterInterface::class)
41+
$logger ?? app(HttpLoggerInterface::class),
42+
$filter ?? app(HttpLoggingFilterInterface::class)
4343
))->__invoke($context, $config));
4444
});
4545

0 commit comments

Comments
 (0)