Skip to content

Commit

Permalink
drop support for laravel 10/monolog < 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 12, 2025
1 parent b107661 commit a74ac17
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 21 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [8.4, 8.3]
laravel: [11.*, 10.*]
laravel: [11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
dependencies: "guzzlehttp/guzzle:^7.8"

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

Expand All @@ -47,9 +44,6 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
if [[ -n "${{ matrix.dependencies }}" ]]; then
composer require ${{ matrix.dependencies }} --no-interaction --no-update
fi
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

A Laravel package that automatically creates GitHub issues from your application logs. Perfect for smaller projects where full-featured logging services like Sentry or Bugsnag might be overkill, but you still want to track bugs effectively.

## Requirements

- PHP ^8.3
- Laravel ^11.0
- Monolog ^3.6

## Features

- ✨ Automatically creates GitHub issues from log entries
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
],
"require": {
"php": "^8.3",
"illuminate/contracts": "^10.0||^11.0",
"illuminate/http": "^10.0||^11.0",
"illuminate/support": "^10.0||^11.0",
"illuminate/filesystem": "^10.0||^11.0"
"laravel/framework": "^11.0",
"monolog/monolog": "^3.6"
},
"require-dev": {
"laravel/pint": "^1.14",
Expand Down
4 changes: 2 additions & 2 deletions src/DefaultSignatureGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function generate(LogRecord $record): string
*/
private function generateFromMessage(LogRecord $record): string
{
return md5($record->message.json_encode($record->context));
return md5($record->message . json_encode($record->context));
}

/**
Expand All @@ -42,7 +42,7 @@ private function generateFromException(Throwable $exception): string
$exception::class,
$exception->getFile(),
$exception->getLine(),
$firstFrame ? ($firstFrame['file'] ?? '').':'.($firstFrame['line'] ?? '') : '',
$firstFrame ? ($firstFrame['file'] ?? '') . ':' . ($firstFrame['line'] ?? '') : '',
]));
}
}
7 changes: 0 additions & 7 deletions src/Handlers/SignatureDeduplicationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ public function __construct(
$this->signatureGenerator = $signatureGenerator ?? new DefaultSignatureGenerator;
}

/**
* Override isDuplicate to use our signature-based deduplication
*/
protected function isDuplicate(array $store, LogRecord $record): bool
{
$timestampValidity = $record->datetime->getTimestamp() - $this->time;
$signature = $this->signatureGenerator->generate($record);

foreach ($store as $entry) {
[$timestamp, $storedSignature] = explode(':', $entry, 2);

if ($storedSignature === $signature && $timestamp > $timestampValidity) {
return true;
}
Expand All @@ -44,9 +40,6 @@ protected function isDuplicate(array $store, LogRecord $record): bool
return false;
}

/**
* Override store entry format to use our signature
*/
protected function buildDeduplicationStoreEntry(LogRecord $record): string
{
return $record->datetime->getTimestamp().':'.$this->signatureGenerator->generate($record);
Expand Down
1 change: 0 additions & 1 deletion tests/Handlers/SignatureDeduplicationHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
// Verify deduplication store contains both unique signatures
$this->handler->close();
$contents = file_get_contents($this->deduplicationStore);
dd($contents);
expect($contents)
->toContain($this->signatureGenerator->generate($record1))
->toContain($this->signatureGenerator->generate($record3));
Expand Down

0 comments on commit a74ac17

Please sign in to comment.