Skip to content

Commit 5092d53

Browse files
authored
Merge pull request #323 from luanfreitasdev/feat/laravel11
Support Laravel 11
2 parents 79bfe71 + 27cffd5 commit 5092d53

File tree

11 files changed

+47
-27
lines changed

11 files changed

+47
-27
lines changed

.github/workflows/run-tests.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
16-
php: [8.1, 8.0]
16+
php: ['8.2', '8.1', '8.0']
1717
laravel: [9.*, 10.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
exclude:
2020
- php: 8.0
2121
laravel: 10.*
22+
- php: 8.0
23+
laravel: 11.*
24+
- php: 8.1
25+
laravel: 11.*
26+
- php: 8.2
27+
laravel: 9.*
2228
include:
2329
- laravel: 9.*
2430
testbench: 7.*
@@ -28,12 +34,16 @@ jobs:
2834
testbench: 8.*
2935
pest: 2.*
3036
collision: 7.*
37+
- laravel: 11.*
38+
testbench: 9.*
39+
pest: 2.*
40+
collision: 8.*
3141

3242
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
3343

3444
steps:
3545
- name: Checkout code
36-
uses: actions/checkout@v3
46+
uses: actions/checkout@v4
3747

3848
- name: Setup PHP
3949
uses: shivammathur/setup-php@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.idea
22
.DS_Store
33
.phpunit.result.cache
4+
.phpunit.cache
45
build
56
composer.lock
67
coverage

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
],
2121
"require": {
2222
"php": "^8.0",
23-
"illuminate/contracts": "^8.0|^9.0|^10.0",
23+
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0",
2424
"opcodesio/mail-parser": "^0.1.6"
2525
},
2626
"require-dev": {
2727
"guzzlehttp/guzzle": "^7.2",
2828
"itsgoingd/clockwork": "^5.1",
2929
"laravel/pint": "^1.0",
30-
"nunomaduro/collision": "^7.0",
31-
"orchestra/testbench": "^7.6|^8.0",
30+
"nunomaduro/collision": "^7.0|^8.0",
31+
"orchestra/testbench": "^7.6|^8.0|^9.0",
3232
"pestphp/pest": "^2.0",
3333
"pestphp/pest-plugin-laravel": "^2.0",
3434
"spatie/test-time": "^1.3"

src/Logs/HorizonLog.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class HorizonLog extends Log
1919

2020
protected function fillMatches(array $matches = []): void
2121
{
22-
$this->datetime = $this->parseDatetime($matches['datetime'])?->tz(
23-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
24-
);
22+
$datetime = $this->parseDateTime($matches['datetime'] ?? null);
23+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
24+
$this->datetime = $datetime?->setTimezone($timezone);
25+
2526
$this->level = $matches['level'];
2627
$this->message = $matches['message'];
2728
$this->context = array_filter([

src/Logs/HorizonOldLog.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ class HorizonOldLog extends Log
1818

1919
protected function fillMatches(array $matches = []): void
2020
{
21-
$this->datetime = $this->parseDatetime($matches['datetime'])?->tz(
22-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
23-
);
21+
$datetime = static::parseDateTime($matches['datetime'] ?? null);
22+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
23+
$this->datetime = $datetime?->setTimezone($timezone);
24+
2425
$this->level = $matches['level'];
2526
$this->message = $matches['message'];
2627
$this->context = [

src/Logs/HttpAccessLog.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ protected function fillMatches(array $matches = []): void
3434
'user_agent' => $matches['user_agent'] ?? null,
3535
];
3636

37-
$this->datetime = static::parseDateTime($matches['datetime'] ?? null)?->tz(
38-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
39-
);
37+
$datetime = static::parseDateTime($matches['datetime'] ?? null);
38+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
39+
$this->datetime = $datetime?->setTimezone($timezone);
40+
4041
$this->level = $matches['status_code'] ?? null;
4142
$this->message = sprintf(
4243
'%s %s',

src/Logs/HttpApacheErrorLog.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ class HttpApacheErrorLog extends Log
1414

1515
protected function fillMatches(array $matches = []): void
1616
{
17-
$this->datetime = static::parseDateTime($matches['datetime'] ?? null)?->tz(
18-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
19-
);
17+
$datetime = static::parseDateTime($matches['datetime'] ?? null);
18+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
19+
$this->datetime = $datetime?->setTimezone($timezone);
20+
2021
$this->level = $matches['level'] ?? null;
2122
$this->message = $matches['message'] ?? null;
2223

src/Logs/HttpNginxErrorLog.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ class HttpNginxErrorLog extends Log
1414

1515
protected function fillMatches(array $matches = []): void
1616
{
17-
$this->datetime = static::parseDateTime($matches['datetime'] ?? null)?->tz(
18-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
19-
);
17+
$datetime = static::parseDateTime($matches['datetime'] ?? null);
18+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
19+
$this->datetime = $datetime?->setTimezone($timezone);
20+
2021
$this->level = $matches['level'] ?? null;
2122
$this->message = $matches['errormessage'] ?? null;
2223

src/Logs/LaravelLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ protected function parseText(array &$matches = []): void
3838

3939
preg_match(static::regexPattern(), array_shift($firstLineSplit), $matches);
4040

41-
$this->datetime = Carbon::parse($matches[1])->tz(
42-
config('log-viewer.timezone', config('app.timezone', 'UTC'))
41+
$this->datetime = Carbon::parse($matches[1])?->setTimezone(
42+
config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC'
4343
);
4444

4545
// $matches[2] contains microseconds, which is already handled

src/Logs/Log.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public static function matches(string $text, ?int &$timestamp = null, ?string &$
6767

6868
if ($result) {
6969
try {
70-
$timestamp = static::parseDateTime($matches[static::$regexDatetimeKey] ?? null)?->timestamp;
70+
$datetime = static::parseDateTime($matches[static::$regexDatetimeKey] ?? null);
71+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
72+
$timestamp = $datetime?->setTimezone($timezone)->timestamp;
73+
7174
$level = $matches[static::$regexLevelKey] ?? '';
7275
} catch (\Exception $exception) {
7376
// not a valid datetime, so we can't match this log. Perhaps it's a different but similar log type.
@@ -104,9 +107,10 @@ protected function parseText(array &$matches = []): void
104107

105108
protected function fillMatches(array $matches = []): void
106109
{
107-
$this->datetime = static::parseDatetime($matches[static::$regexDatetimeKey] ?? null)?->tz(
108-
config('log-viewer.timezone', config('app.timezone'))
109-
);
110+
$datetime = static::parseDateTime($matches[static::$regexDatetimeKey] ?? null);
111+
$timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC';
112+
$this->datetime = $datetime?->setTimezone($timezone);
113+
110114
$this->level = $matches[static::$regexLevelKey] ?? null;
111115
$this->message = trim($matches[static::$regexMessageKey] ?? null);
112116
$this->context = [];

0 commit comments

Comments
 (0)