Skip to content

Commit

Permalink
Merge pull request #50 from jesperbeisner/feature/make-laravel-11-ready
Browse files Browse the repository at this point in the history
WIP - feature: make laravel 11 ready
  • Loading branch information
hedii authored Mar 13, 2024
2 parents 90c80b7 + cc0664c commit 451adf8
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.1', '8.2' ]
php-versions: [ '8.2' ]
name: Testing on PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| 8.0 | ^6.0 (with php 8) |
| 9.0 | ^7.0 |
| 10.0 | ^8.0 |
| 11.0 | ^9.0 |

A package to send [gelf](http://docs.graylog.org/en/2.1/pages/gelf.html) logs to a gelf compatible backend like graylog. It is a Laravel wrapper for [bzikarsky/gelf-php](https://github.com/bzikarsky/gelf-php) package.

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"source": "https://github.com/hedii/laravel-gelf-logger"
},
"require": {
"php": "^8.1",
"php": "^8.2",
"graylog2/gelf-php": "^2.0",
"illuminate/log": "^10.0"
"illuminate/log": "^11.0"
},
"require-dev": {
"orchestra/testbench": "^8.0"
"orchestra/testbench": "^9.0"
},
"autoload": {
"psr-4": {
Expand Down
39 changes: 20 additions & 19 deletions tests/GelfLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
use Monolog\Handler\GelfHandler;
use Monolog\Level;
use Monolog\Logger;
use PHPUnit\Framework\Attributes\Test;

class GelfLoggerTest extends TestCase
{
/** @test */
#[Test]
public function it_should_have_a_gelf_log_channel(): void
{
$logger = Log::channel('gelf');
Expand All @@ -40,7 +41,7 @@ public function it_should_have_a_gelf_log_channel(): void
$this->assertInstanceOf(UdpTransport::class, $transport);
}

/** @test */
#[Test]
public function it_should_not_have_any_processor_if_the_config_does_not_have_processors(): void
{
$this->expectException(LogicException::class);
Expand All @@ -52,7 +53,7 @@ public function it_should_not_have_any_processor_if_the_config_does_not_have_pro
$handler->popProcessor();
}

/** @test */
#[Test]
public function it_should_set_system_name_to_current_hostname_if_system_name_is_null(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -69,7 +70,7 @@ public function it_should_set_system_name_to_current_hostname_if_system_name_is_
);
}

/** @test */
#[Test]
public function it_should_set_system_name_to_custom_value_if_system_name_config_is_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -86,7 +87,7 @@ public function it_should_set_system_name_to_custom_value_if_system_name_config_
);
}

/** @test */
#[Test]
public function it_should_call_the_tcp_transport_method_when_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -102,7 +103,7 @@ public function it_should_call_the_tcp_transport_method_when_provided(): void
$this->assertInstanceOf(TcpTransport::class, $transport);
}

/** @test */
#[Test]
public function it_should_call_the_udp_transport_method_when_nothing_is_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -117,7 +118,7 @@ public function it_should_call_the_udp_transport_method_when_nothing_is_provided
$this->assertInstanceOf(UdpTransport::class, $transport);
}

/** @test */
#[Test]
public function it_should_set_max_length_if_max_length_is_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -134,7 +135,7 @@ public function it_should_set_max_length_if_max_length_is_provided(): void
);
}

/** @test */
#[Test]
public function it_should_use_default_max_length_when_max_length_is_not_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -150,7 +151,7 @@ public function it_should_use_default_max_length_when_max_length_is_not_provided
);
}

/** @test */
#[Test]
public function it_should_use_default_max_length_when_max_length_is_null(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -167,7 +168,7 @@ public function it_should_use_default_max_length_when_max_length_is_null(): void
);
}

/** @test */
#[Test]
public function it_should_call_the_http_transport_method_when_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -183,7 +184,7 @@ public function it_should_call_the_http_transport_method_when_provided(): void
$this->assertInstanceOf(HttpTransport::class, $transport);
}

/** @test */
#[Test]
public function it_should_set_path_if_path_is_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -201,7 +202,7 @@ public function it_should_set_path_if_path_is_provided(): void
$this->assertSame('/custom-path', $this->getAttribute($transport, 'path'));
}

/** @test */
#[Test]
public function it_should_set_path_to_default_path_if_path_is_null(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -222,7 +223,7 @@ public function it_should_set_path_to_default_path_if_path_is_null(): void
);
}

/** @test */
#[Test]
public function it_should_set_path_to_default_path_if_path_is_not_provided(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -242,7 +243,7 @@ public function it_should_set_path_to_default_path_if_path_is_not_provided(): vo
);
}

/** @test */
#[Test]
public function it_should_set_the_ssl_options_for_tcp_transport(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down Expand Up @@ -272,7 +273,7 @@ public function it_should_set_the_ssl_options_for_tcp_transport(): void
$this->assertEquals('TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256', $sslOptions->getCiphers());
}

/** @test */
#[Test]
public function it_should_set_the_ssl_options_for_http_transport(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down Expand Up @@ -303,7 +304,7 @@ public function it_should_set_the_ssl_options_for_http_transport(): void
}


/** @test */
#[Test]
public function it_should_not_add_ssl_on_tcp_transport_when_the_ssl_config_is_missing_or_set_to_false(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down Expand Up @@ -346,7 +347,7 @@ public function it_should_not_add_ssl_on_tcp_transport_when_the_ssl_config_is_mi
$this->assertNull($this->getAttribute($transport, 'sslOptions'));
}

/** @test */
#[Test]
public function it_should_not_add_ssl_on_http_transport_when_the_ssl_config_is_missing_or_set_to_false(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down Expand Up @@ -387,7 +388,7 @@ public function it_should_not_add_ssl_on_http_transport_when_the_ssl_config_is_m
$this->assertNull($this->getAttribute($transport, 'sslOptions'));
}

/** @test */
#[Test]
public function it_should_use_the_default_ssl_options_when_ssl_options_is_missing(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down Expand Up @@ -431,7 +432,7 @@ public function it_should_use_the_default_ssl_options_when_ssl_options_is_missin
$this->assertNull($sslOptions->getCiphers());
}

/** @test */
#[Test]
public function it_should_ignore_errors_when_the_ignore_error_config_is_missing_or_set_to_false(): void
{
$this->app['config']->set('logging.default', 'gelf');
Expand Down
7 changes: 4 additions & 3 deletions tests/GelfMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use Illuminate\Support\Facades\Log;
use Monolog\Level;
use Monolog\LogRecord;
use PHPUnit\Framework\Attributes\Test;

class GelfMessageTest extends TestCase
{
/** @test */
#[Test]
public function it_should_append_prefixes(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -36,7 +37,7 @@ public function it_should_append_prefixes(): void
$this->assertArrayHasKey('ctxt_message', $formattedMessage->getAllAdditionals());
}

/** @test */
#[Test]
public function it_should_not_append_prefixes(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand All @@ -58,7 +59,7 @@ public function it_should_not_append_prefixes(): void
$this->assertArrayHasKey('id', $formattedMessage->getAllAdditionals());
}

/** @test */
#[Test]
public function null_config_variables_should_not_add_prefixes(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down
3 changes: 2 additions & 1 deletion tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
use Hedii\LaravelGelfLogger\Tests\Fake\AnotherTestProcessor;
use Hedii\LaravelGelfLogger\Tests\Fake\TestProcessor;
use Illuminate\Support\Facades\Log;
use PHPUnit\Framework\Attributes\Test;

class ProcessorTest extends TestCase
{
/** @test */
#[Test]
public function it_should_have_the_configured_processors(): void
{
$this->mergeConfig('logging.channels.gelf', [
Expand Down
4 changes: 2 additions & 2 deletions tests/Processors/NullStringProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Hedii\LaravelGelfLogger\Tests\Processors;

use Carbon\Carbon;
use DateTimeImmutable;
use Hedii\LaravelGelfLogger\Processors\NullStringProcessor;
use Monolog\Level;
use Monolog\LogRecord;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class NullStringProcessorTest extends TestCase
{
/** @test */
#[Test]
public function it_should_transform_null_string_to_null(): void
{
$payload = new LogRecord(
Expand Down
8 changes: 4 additions & 4 deletions tests/Processors/RenameIdFieldProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use Hedii\LaravelGelfLogger\Processors\RenameIdFieldProcessor;
use Monolog\Level;
use Monolog\LogRecord;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class RenameIdFieldProcessorTest extends TestCase
{
/**
* @test
* @dataProvider dataProvider
*/
#[Test]
#[DataProvider('dataProvider')]
public function it_should_rename_id_field(array $payloadContext, array $expected): void
{
$payload = new LogRecord(
Expand Down

0 comments on commit 451adf8

Please sign in to comment.