Skip to content

Commit

Permalink
Add Laravel 10 support (#13)
Browse files Browse the repository at this point in the history
* Add Laravel 10 support

* Fix Laravel 10 for NonConsole

* Repair test by allowing dependencies upgrade

---------

Co-authored-by: Mitchell M <[email protected]>
  • Loading branch information
LVMade01 and VeryStrongFingers committed Feb 17, 2023
1 parent d14324b commit 6b0e069
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/laravel-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
laravel: ^8.0
- php: 8.1
laravel: ^9.0
- php: 8.2
laravel: ^10.0

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand Down Expand Up @@ -87,7 +89,7 @@ jobs:
cd laravel-app
ls -lha
cat composer.json
composer update --no-interaction --no-progress
composer update --no-interaction --no-progress --with-all-dependencies
php artisan package:discover --ansi
php artisan clear-compiled
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ php artisan my:command -vvv

| Compatible | Laravel |
|--------------------|---------|
| :heavy_check_mark: | 9.* |
| :heavy_check_mark: | 8.* |
| :heavy_check_mark: | 7.* |
| :heavy_check_mark: | 6.* |
| :heavy_check_mark: | 10.* |
| :heavy_check_mark: | 9.* |
| :heavy_check_mark: | 8.* |
| :heavy_check_mark: | 7.* |
| :heavy_check_mark: | 6.* |

---

Expand Down
18 changes: 14 additions & 4 deletions src/LogHandlers/ConsoleApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,29 @@ public function getProcessors(): array
return [];
}

public function isHandling(array $record): bool
/**
* @param array|Monolog\LogRecord $record
*/
public function isHandling($record): bool
{
return true;
}

public function handle(array $record): bool
/**
* @param array|Monolog\LogRecord $record
*/
public function handle($record): bool
{
$this->log(strtolower($record['level_name'] ?? ''), $record['message'] ?? '', $record['context'] ?? []);
$recordArray = is_array($record) ? $record : $record->toArray();
$this->log(strtolower($recordArray['level_name'] ?? ''), $recordArray['message'] ?? '', $recordArray['context'] ?? []);

return true;
}

public function handleBatch(array $records): void
/**
* @param array|Monolog\LogRecord $record
*/
public function handleBatch($records): void
{
foreach ($records as $record) {
$this->handle($record);
Expand Down
15 changes: 12 additions & 3 deletions src/LogHandlers/NonConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public function getHandlers(): array
return [];
}

public function isHandling(array $record): bool
/**
* @param array|Monolog\LogRecord $record
*/
public function isHandling($record): bool
{
return false;
}
Expand All @@ -25,12 +28,18 @@ public function getProcessors(): array
return [];
}

public function handle(array $record): bool
/**
* @param array|Monolog\LogRecord $record
*/
public function handle($record): bool
{
return false;
}

public function handleBatch(array $records): void
/**
* @param array|Monolog\LogRecord $record
*/
public function handleBatch($records): void
{
}

Expand Down

0 comments on commit 6b0e069

Please sign in to comment.