Skip to content

removed support for php 8.2 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Tests
name: CI

on:
push:
pull_request:
release:
types:
- published
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
Expand All @@ -16,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.2, 8.3, 8.4]
php: [8.3, 8.4]
laravel: [10.*, 11.*, 12.*]
os: [ubuntu-latest]
coverage: [none]
Expand Down Expand Up @@ -52,6 +50,9 @@ jobs:
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs

- name: Execute linter
run: composer check

- name: Execute tests (Unit and Feature tests) via PHPUnit
if: matrix.coverage == 'none'
run: composer test
Expand All @@ -65,10 +66,11 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: matrix.coverage == 'xdebug'
slug: aporat/laravel-cloudwatch-logger
slug: ${{ github.repository }}

- name: Upload test results to Codecov
if: matrix.coverage == 'xdebug'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
31 changes: 0 additions & 31 deletions .github/workflows/linter.yml

This file was deleted.

7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
[![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)
[![Codecov](https://img.shields.io/codecov/c/github/aporat/laravel-cloudwatch-logger?style=flat-square)](https://codecov.io/github/aporat/laravel-cloudwatch-logger)
[![Laravel Version](https://img.shields.io/badge/Laravel-12.x-orange.svg?style=flat-square)](https://laravel.com/docs/12.x)
[![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)
[![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)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/aporat/laravel-cloudwatch-logger/ci.yml?style=flat-square)
[![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)

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

## Requirements
- **PHP**: 8.2 or higher
- **PHP**: 8.3 or higher
- **Laravel**: 10.x, 11.x, 12.x
- **AWS SDK**: Provided via `phpnexus/cwh` dependency

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"require": {
"php": "^8.2",
"php": "^8.3",
"ext-json": "*",
"illuminate/support": "^10.0 || ^11.0 || ^12.0",
"illuminate/log": "^10.0 || ^11.0 || ^12.0",
Expand Down
22 changes: 11 additions & 11 deletions config/cloudwatch-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
*/
'cloudwatch' => [
'driver' => 'custom',
'via' => \Aporat\CloudWatchLogger\CloudWatchLoggerFactory::class,
'aws' => [
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'version' => env('AWS_VERSION', 'latest'),
'via' => \Aporat\CloudWatchLogger\CloudWatchLoggerFactory::class,
'aws' => [
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'version' => env('AWS_VERSION', 'latest'),
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID', ''),
'key' => env('AWS_ACCESS_KEY_ID', ''),
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
],
],
'group' => env('CLOUDWATCH_LOG_GROUP_NAME', env('APP_NAME', 'laravel').'-'.env('APP_ENV', 'production')),
'stream' => env('CLOUDWATCH_LOG_STREAM', 'default'),
'name' => env('CLOUDWATCH_LOG_NAME', env('APP_NAME', 'laravel')),
'retention' => env('CLOUDWATCH_LOG_RETENTION', 14),
'level' => env('CLOUDWATCH_LOG_LEVEL', \Monolog\Level::Error->value),
'group' => env('CLOUDWATCH_LOG_GROUP_NAME', env('APP_NAME', 'laravel').'-'.env('APP_ENV', 'production')),
'stream' => env('CLOUDWATCH_LOG_STREAM', 'default'),
'name' => env('CLOUDWATCH_LOG_NAME', env('APP_NAME', 'laravel')),
'retention' => env('CLOUDWATCH_LOG_RETENTION', 14),
'level' => env('CLOUDWATCH_LOG_LEVEL', \Monolog\Level::Error->value),
'batch_size' => env('CLOUDWATCH_LOG_BATCH_SIZE', 10000),
'formatter' => function (array $config) {
'formatter' => function (array $config) {
return new \Monolog\Formatter\LineFormatter(
format: '%channel%: %level_name%: %message% %context% %extra%',
dateFormat: null,
Expand Down
27 changes: 12 additions & 15 deletions src/CloudWatchLoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class CloudWatchLoggerFactory
/**
* Create a new CloudWatch logger factory instance.
*
* @param Container|null $container Laravel container instance (optional, defaults to null)
* @param Container|null $container Laravel container instance (optional, defaults to null)
*/
public function __construct(?Container $container = null)
{
Expand All @@ -39,11 +39,10 @@ public function __construct(?Container $container = null)
/**
* Create a configured CloudWatch logger instance.
*
* @param array<string, mixed> $config Configuration array for CloudWatch logging
* @param array<string, mixed> $config Configuration array for CloudWatch logging
* @return Logger Configured Monolog logger instance
*
* @throws IncompleteCloudWatchConfig If required config is missing or invalid
*
* @return Logger Configured Monolog logger instance
*/
public function __invoke(array $config): Logger
{
Expand All @@ -68,15 +67,14 @@ public function __invoke(array $config): Logger
/**
* Resolve the formatter for CloudWatch logs based on configuration.
*
* @param array<string, mixed> $config Configuration array with optional formatter settings
* @param array<string, mixed> $config Configuration array with optional formatter settings
* @return FormatterInterface Formatter instance for Monolog
*
* @throws IncompleteCloudWatchConfig If formatter configuration is invalid
*
* @return FormatterInterface Formatter instance for Monolog
*/
private function resolveFormatter(array $config): FormatterInterface
{
if (!isset($config['formatter'])) {
if (! isset($config['formatter'])) {
return new LineFormatter(
'%channel%: %level_name%: %message% %context% %extra%',
null,
Expand All @@ -88,8 +86,8 @@ private function resolveFormatter(array $config): FormatterInterface
$formatter = $config['formatter'];

if (is_string($formatter) && class_exists($formatter)) {
if (!$this->container) {
return new $formatter();
if (! $this->container) {
return new $formatter;
}

return $this->container->make($formatter);
Expand All @@ -105,13 +103,12 @@ private function resolveFormatter(array $config): FormatterInterface
/**
* Validate and retrieve a required configuration value.
*
* @param array<string, mixed> $config Configuration array
* @param string $key Config key to retrieve
* @param string $description Description of the key for error messaging
* @param array<string, mixed> $config Configuration array
* @param string $key Config key to retrieve
* @param string $description Description of the key for error messaging
* @return mixed Config value
*
* @throws IncompleteCloudWatchConfig If the key is missing or empty
*
* @return mixed Config value
*/
private function validateConfig(array $config, string $key, string $description): mixed
{
Expand Down
6 changes: 3 additions & 3 deletions src/Exceptions/IncompleteCloudWatchConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class IncompleteCloudWatchConfig extends Exception
/**
* Create a new incomplete CloudWatch configuration exception.
*
* @param string $message The exception message (default: 'Incomplete CloudWatch configuration')
* @param int $code The exception code (default: 0)
* @param Exception|null $previous The previous exception for chaining (default: null)
* @param string $message The exception message (default: 'Incomplete CloudWatch configuration')
* @param int $code The exception code (default: 0)
* @param Exception|null $previous The previous exception for chaining (default: null)
*/
public function __construct(string $message = 'Incomplete CloudWatch configuration', int $code = 0, ?Exception $previous = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/CloudWatchLoggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CloudWatchLoggerServiceProvider extends ServiceProvider implements Deferra
*
* @var string
*/
private const CONFIG_PATH = __DIR__.'/../../config/cloudwatch-logger.php';
private const string CONFIG_PATH = __DIR__.'/../../config/cloudwatch-logger.php';

/**
* Register services with the container.
Expand Down
4 changes: 2 additions & 2 deletions tests/CloudWatchLoggerServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function test_publishes_configuration(): void

$this->artisan('vendor:publish', [
'--provider' => CloudWatchLoggerServiceProvider::class,
'--tag' => 'config',
'--force' => true,
'--tag' => 'config',
'--force' => true,
]);

$this->assertFileExists($targetPath, 'Config file should be published');
Expand Down
29 changes: 14 additions & 15 deletions tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function test_throws_exception_for_invalid_formatter(): void
public function test_creates_logger_with_line_formatter_callable(): void
{
$config = $this->getBaseConfig([
'group' => 'myapp-testing',
'stream' => 'default',
'name' => 'default',
'group' => 'myapp-testing',
'stream' => 'default',
'name' => 'default',
'formatter' => fn (array $configs) => new LineFormatter(
'%channel%: %level_name%: %message% %context% %extra%',
null,
Expand All @@ -81,7 +81,7 @@ public function test_creates_logger_with_line_formatter_callable(): void
Level::Error,
'Test log message',
['user_id' => 123],
['key' => 'value']
['key' => 'value']
);
$formatted = $formatter->format($record);

Expand All @@ -97,28 +97,27 @@ protected function tearDown(): void
/**
* Generate a base CloudWatch configuration with optional overrides.
*
* @param array<string, mixed> $overrides Custom config values to merge
*
* @param array<string, mixed> $overrides Custom config values to merge
* @return array<string, mixed> Complete config array
*/
private function getBaseConfig(array $overrides = []): array
{
return array_merge([
'driver' => 'custom',
'via' => CloudWatchLoggerFactory::class,
'aws' => [
'region' => 'us-east-1',
'version' => 'latest',
'via' => CloudWatchLoggerFactory::class,
'aws' => [
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => 'AWS_ACCESS_KEY_ID',
'key' => 'AWS_ACCESS_KEY_ID',
'secret' => 'AWS_SECRET_ACCESS_KEY',
],
],
'name' => 'CLOUDWATCH_LOG_NAME',
'group' => 'CLOUDWATCH_LOG_GROUP_NAME',
'stream' => 'CLOUDWATCH_LOG_STREAM',
'name' => 'CLOUDWATCH_LOG_NAME',
'group' => 'CLOUDWATCH_LOG_GROUP_NAME',
'stream' => 'CLOUDWATCH_LOG_STREAM',
'retention' => 7,
'level' => Level::Error,
'level' => Level::Error,
], $overrides);
}
}
Loading