Skip to content

Commit b66a480

Browse files
committed
removed support for php 8.2
1 parent 5d38252 commit b66a480

10 files changed

+54
-88
lines changed

.github/workflows/tests.yml renamed to .github/workflows/ci.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
name: Tests
1+
name: CI
22

33
on:
44
push:
55
pull_request:
66
release:
77
types:
88
- published
9-
schedule:
10-
- cron: '0 0 * * *'
119

1210
jobs:
1311
php-tests:
@@ -16,7 +14,7 @@ jobs:
1614
strategy:
1715
fail-fast: false
1816
matrix:
19-
php: [8.2, 8.3, 8.4]
17+
php: [8.3, 8.4]
2018
laravel: [10.*, 11.*, 12.*]
2119
os: [ubuntu-latest]
2220
coverage: [none]
@@ -52,6 +50,9 @@ jobs:
5250
- name: Install Dependencies
5351
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
5452

53+
- name: Execute linter
54+
run: composer check
55+
5556
- name: Execute tests (Unit and Feature tests) via PHPUnit
5657
if: matrix.coverage == 'none'
5758
run: composer test
@@ -65,10 +66,11 @@ jobs:
6566
with:
6667
token: ${{ secrets.CODECOV_TOKEN }}
6768
if: matrix.coverage == 'xdebug'
68-
slug: aporat/laravel-cloudwatch-logger
69+
slug: ${{ github.repository }}
6970

7071
- name: Upload test results to Codecov
7172
if: matrix.coverage == 'xdebug'
7273
uses: codecov/test-results-action@v1
7374
with:
7475
token: ${{ secrets.CODECOV_TOKEN }}
76+
slug: ${{ github.repository }}

.github/workflows/linter.yml

-31
This file was deleted.

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
[![Monthly Downloads](https://img.shields.io/packagist/dm/aporat/laravel-cloudwatch-logger.svg?style=flat-square&logo=composer)](https://packagist.org/packages/aporat/laravel-cloudwatch-logger)
55
[![Codecov](https://img.shields.io/codecov/c/github/aporat/laravel-cloudwatch-logger?style=flat-square)](https://codecov.io/github/aporat/laravel-cloudwatch-logger)
66
[![Laravel Version](https://img.shields.io/badge/Laravel-12.x-orange.svg?style=flat-square)](https://laravel.com/docs/12.x)
7-
[![Scrutinizer build (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/build/g/aporat/laravel-cloudwatch-logger?style=flat-square)](https://scrutinizer-ci.com/g/aporat/laravel-cloudwatch-logger/build-status/master)
8-
[![Scrutinizer quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/aporat/laravel-cloudwatch-logger?style=flat-square)](https://scrutinizer-ci.com/g/aporat/laravel-cloudwatch-logger/?branch=master)
7+
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/aporat/laravel-cloudwatch-logger/ci.yml?style=flat-square)
98
[![License](https://img.shields.io/packagist/l/aporat/laravel-cloudwatch-logger.svg?style=flat-square)](https://github.com/aporat/laravel-cloudwatch-logger/blob/master/LICENSE)
109

1110
A Laravel logging driver for seamless integration with AWS CloudWatch Logs.
@@ -14,11 +13,11 @@ A Laravel logging driver for seamless integration with AWS CloudWatch Logs.
1413
- Custom Monolog channel for sending logs to CloudWatch.
1514
- Configurable AWS credentials, log group, stream, and retention period.
1615
- Support for custom log formatters (e.g., JSON, line format).
17-
- Compatible with Laravel’s native logging system via the `Log` facade.
16+
- Compatible with Laravel native logging system via the `Log` facade.
1817
- Built-in configuration publishing for easy setup.
1918

2019
## Requirements
21-
- **PHP**: 8.2 or higher
20+
- **PHP**: 8.3 or higher
2221
- **Laravel**: 10.x, 11.x, 12.x
2322
- **AWS SDK**: Provided via `phpnexus/cwh` dependency
2423

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^8.2",
24+
"php": "^8.3",
2525
"ext-json": "*",
2626
"illuminate/support": "^10.0 || ^11.0 || ^12.0",
2727
"illuminate/log": "^10.0 || ^11.0 || ^12.0",

config/cloudwatch-logger.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
*/
2222
'cloudwatch' => [
2323
'driver' => 'custom',
24-
'via' => \Aporat\CloudWatchLogger\CloudWatchLoggerFactory::class,
25-
'aws' => [
26-
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
27-
'version' => env('AWS_VERSION', 'latest'),
24+
'via' => \Aporat\CloudWatchLogger\CloudWatchLoggerFactory::class,
25+
'aws' => [
26+
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
27+
'version' => env('AWS_VERSION', 'latest'),
2828
'credentials' => [
29-
'key' => env('AWS_ACCESS_KEY_ID', ''),
29+
'key' => env('AWS_ACCESS_KEY_ID', ''),
3030
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
3131
],
3232
],
33-
'group' => env('CLOUDWATCH_LOG_GROUP_NAME', env('APP_NAME', 'laravel').'-'.env('APP_ENV', 'production')),
34-
'stream' => env('CLOUDWATCH_LOG_STREAM', 'default'),
35-
'name' => env('CLOUDWATCH_LOG_NAME', env('APP_NAME', 'laravel')),
36-
'retention' => env('CLOUDWATCH_LOG_RETENTION', 14),
37-
'level' => env('CLOUDWATCH_LOG_LEVEL', \Monolog\Level::Error->value),
33+
'group' => env('CLOUDWATCH_LOG_GROUP_NAME', env('APP_NAME', 'laravel').'-'.env('APP_ENV', 'production')),
34+
'stream' => env('CLOUDWATCH_LOG_STREAM', 'default'),
35+
'name' => env('CLOUDWATCH_LOG_NAME', env('APP_NAME', 'laravel')),
36+
'retention' => env('CLOUDWATCH_LOG_RETENTION', 14),
37+
'level' => env('CLOUDWATCH_LOG_LEVEL', \Monolog\Level::Error->value),
3838
'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
39-
'formatter' => function (array $config) {
39+
'formatter' => function (array $config) {
4040
return new \Monolog\Formatter\LineFormatter(
4141
format: '%channel%: %level_name%: %message% %context% %extra%',
4242
dateFormat: null,

src/CloudWatchLoggerFactory.php

+12-15
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class CloudWatchLoggerFactory
2929
/**
3030
* Create a new CloudWatch logger factory instance.
3131
*
32-
* @param Container|null $container Laravel container instance (optional, defaults to null)
32+
* @param Container|null $container Laravel container instance (optional, defaults to null)
3333
*/
3434
public function __construct(?Container $container = null)
3535
{
@@ -39,11 +39,10 @@ public function __construct(?Container $container = null)
3939
/**
4040
* Create a configured CloudWatch logger instance.
4141
*
42-
* @param array<string, mixed> $config Configuration array for CloudWatch logging
42+
* @param array<string, mixed> $config Configuration array for CloudWatch logging
43+
* @return Logger Configured Monolog logger instance
4344
*
4445
* @throws IncompleteCloudWatchConfig If required config is missing or invalid
45-
*
46-
* @return Logger Configured Monolog logger instance
4746
*/
4847
public function __invoke(array $config): Logger
4948
{
@@ -68,15 +67,14 @@ public function __invoke(array $config): Logger
6867
/**
6968
* Resolve the formatter for CloudWatch logs based on configuration.
7069
*
71-
* @param array<string, mixed> $config Configuration array with optional formatter settings
70+
* @param array<string, mixed> $config Configuration array with optional formatter settings
71+
* @return FormatterInterface Formatter instance for Monolog
7272
*
7373
* @throws IncompleteCloudWatchConfig If formatter configuration is invalid
74-
*
75-
* @return FormatterInterface Formatter instance for Monolog
7674
*/
7775
private function resolveFormatter(array $config): FormatterInterface
7876
{
79-
if (!isset($config['formatter'])) {
77+
if (! isset($config['formatter'])) {
8078
return new LineFormatter(
8179
'%channel%: %level_name%: %message% %context% %extra%',
8280
null,
@@ -88,8 +86,8 @@ private function resolveFormatter(array $config): FormatterInterface
8886
$formatter = $config['formatter'];
8987

9088
if (is_string($formatter) && class_exists($formatter)) {
91-
if (!$this->container) {
92-
return new $formatter();
89+
if (! $this->container) {
90+
return new $formatter;
9391
}
9492

9593
return $this->container->make($formatter);
@@ -105,13 +103,12 @@ private function resolveFormatter(array $config): FormatterInterface
105103
/**
106104
* Validate and retrieve a required configuration value.
107105
*
108-
* @param array<string, mixed> $config Configuration array
109-
* @param string $key Config key to retrieve
110-
* @param string $description Description of the key for error messaging
106+
* @param array<string, mixed> $config Configuration array
107+
* @param string $key Config key to retrieve
108+
* @param string $description Description of the key for error messaging
109+
* @return mixed Config value
111110
*
112111
* @throws IncompleteCloudWatchConfig If the key is missing or empty
113-
*
114-
* @return mixed Config value
115112
*/
116113
private function validateConfig(array $config, string $key, string $description): mixed
117114
{

src/Exceptions/IncompleteCloudWatchConfig.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class IncompleteCloudWatchConfig extends Exception
1717
/**
1818
* Create a new incomplete CloudWatch configuration exception.
1919
*
20-
* @param string $message The exception message (default: 'Incomplete CloudWatch configuration')
21-
* @param int $code The exception code (default: 0)
22-
* @param Exception|null $previous The previous exception for chaining (default: null)
20+
* @param string $message The exception message (default: 'Incomplete CloudWatch configuration')
21+
* @param int $code The exception code (default: 0)
22+
* @param Exception|null $previous The previous exception for chaining (default: null)
2323
*/
2424
public function __construct(string $message = 'Incomplete CloudWatch configuration', int $code = 0, ?Exception $previous = null)
2525
{

src/Laravel/CloudWatchLoggerServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CloudWatchLoggerServiceProvider extends ServiceProvider implements Deferra
2121
*
2222
* @var string
2323
*/
24-
private const CONFIG_PATH = __DIR__.'/../../config/cloudwatch-logger.php';
24+
private const string CONFIG_PATH = __DIR__.'/../../config/cloudwatch-logger.php';
2525

2626
/**
2727
* Register services with the container.

tests/CloudWatchLoggerServiceProviderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function test_publishes_configuration(): void
4242

4343
$this->artisan('vendor:publish', [
4444
'--provider' => CloudWatchLoggerServiceProvider::class,
45-
'--tag' => 'config',
46-
'--force' => true,
45+
'--tag' => 'config',
46+
'--force' => true,
4747
]);
4848

4949
$this->assertFileExists($targetPath, 'Config file should be published');

tests/LoggerTest.php

+14-15
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function test_throws_exception_for_invalid_formatter(): void
5757
public function test_creates_logger_with_line_formatter_callable(): void
5858
{
5959
$config = $this->getBaseConfig([
60-
'group' => 'myapp-testing',
61-
'stream' => 'default',
62-
'name' => 'default',
60+
'group' => 'myapp-testing',
61+
'stream' => 'default',
62+
'name' => 'default',
6363
'formatter' => fn (array $configs) => new LineFormatter(
6464
'%channel%: %level_name%: %message% %context% %extra%',
6565
null,
@@ -81,7 +81,7 @@ public function test_creates_logger_with_line_formatter_callable(): void
8181
Level::Error,
8282
'Test log message',
8383
['user_id' => 123],
84-
['key' => 'value']
84+
['key' => 'value']
8585
);
8686
$formatted = $formatter->format($record);
8787

@@ -97,28 +97,27 @@ protected function tearDown(): void
9797
/**
9898
* Generate a base CloudWatch configuration with optional overrides.
9999
*
100-
* @param array<string, mixed> $overrides Custom config values to merge
101-
*
100+
* @param array<string, mixed> $overrides Custom config values to merge
102101
* @return array<string, mixed> Complete config array
103102
*/
104103
private function getBaseConfig(array $overrides = []): array
105104
{
106105
return array_merge([
107106
'driver' => 'custom',
108-
'via' => CloudWatchLoggerFactory::class,
109-
'aws' => [
110-
'region' => 'us-east-1',
111-
'version' => 'latest',
107+
'via' => CloudWatchLoggerFactory::class,
108+
'aws' => [
109+
'region' => 'us-east-1',
110+
'version' => 'latest',
112111
'credentials' => [
113-
'key' => 'AWS_ACCESS_KEY_ID',
112+
'key' => 'AWS_ACCESS_KEY_ID',
114113
'secret' => 'AWS_SECRET_ACCESS_KEY',
115114
],
116115
],
117-
'name' => 'CLOUDWATCH_LOG_NAME',
118-
'group' => 'CLOUDWATCH_LOG_GROUP_NAME',
119-
'stream' => 'CLOUDWATCH_LOG_STREAM',
116+
'name' => 'CLOUDWATCH_LOG_NAME',
117+
'group' => 'CLOUDWATCH_LOG_GROUP_NAME',
118+
'stream' => 'CLOUDWATCH_LOG_STREAM',
120119
'retention' => 7,
121-
'level' => Level::Error,
120+
'level' => Level::Error,
122121
], $overrides);
123122
}
124123
}

0 commit comments

Comments
 (0)