Skip to content
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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ jobs:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
uses: innmind/github-workflows/.github/workflows/cs.yml@main
with:
php-version: '8.2'
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.4`
- Requires `innmind/foundation:~2.1`

## 5.4.0 - 2025-07-31

### Changed
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"issues": "http://github.com/Innmind/LogReader/issues"
},
"require": {
"php": "~8.2",
"innmind/foundation": "~1.3",
"php": "~8.4",
"innmind/foundation": "~2.1",
"psr/log": "^3.0"
},
"autoload": {
Expand All @@ -30,7 +30,7 @@
},
"require-dev": {
"innmind/black-box": "^6.4.1",
"innmind/static-analysis": "^1.2.1",
"innmind/static-analysis": "~1.3",
"innmind/coding-standard": "~2.0"
}
}
10 changes: 6 additions & 4 deletions src/LineParser/ApacheAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
Log,
Log\Attribute\Attribute,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
PointInTime,
Point,
Format,
};
use Innmind\Url\{
Expand Down Expand Up @@ -63,7 +63,9 @@ public function __invoke(Str $line): Maybe
->get('time')
->map(static fn($time) => $time->toString())
->keep(Is::string()->nonEmpty()->asPredicate())
->flatMap($this->clock->ofFormat(Format::of('d/M/Y:H:i:s O'))->at(...));
->attempt(static fn() => new \Exception)
->flatMap($this->clock->ofFormat(Format::of('d/M/Y:H:i:s O'))->at(...))
->maybe();
$user = $parts
->get('user')
->map(static fn($user) => Attribute::of('user', $user));
Expand Down Expand Up @@ -106,7 +108,7 @@ public function __invoke(Str $line): Maybe
$code,
$size,
)
->map(static fn(PointInTime $time, Attribute ...$attributes) => Log::of(
->map(static fn(Point $time, Attribute ...$attributes) => Log::of(
$time,
$line,
Set::of(...$attributes),
Expand Down
6 changes: 4 additions & 2 deletions src/LineParser/Monolog.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Log\Attribute\Monolog\Level,
Log\Attribute\Monolog\Message,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
};
Expand Down Expand Up @@ -101,7 +101,9 @@ public function __invoke(Str $line): Maybe
->get('time')
->map(static fn($time) => $time->toString())
->keep(Is::string()->nonEmpty()->asPredicate())
->flatMap($this->clock->ofFormat(Format::of('Y-m-d H:i:s'))->at(...));
->attempt(static fn() => new \Exception)
->flatMap($this->clock->ofFormat(Format::of('Y-m-d H:i:s'))->at(...))
->maybe();

return $time->flatMap(
static fn($time) => $attributes->map(
Expand Down
10 changes: 5 additions & 5 deletions src/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Innmind\LogReader;

use Innmind\LogReader\Log\Attribute;
use Innmind\TimeContinuum\PointInTime;
use Innmind\Time\Point;
use Innmind\Immutable\{
Str,
Set,
Expand All @@ -16,15 +16,15 @@
*/
final class Log
{
private PointInTime $time;
private Point $time;
private Str $raw;
/** @var Set<Attribute> */
private Set $attributes;

/**
* @param Set<Attribute> $attributes
*/
private function __construct(PointInTime $time, Str $raw, Set $attributes)
private function __construct(Point $time, Str $raw, Set $attributes)
{
$this->time = $time;
$this->raw = $raw;
Expand All @@ -36,13 +36,13 @@ private function __construct(PointInTime $time, Str $raw, Set $attributes)
*
* @param Set<Attribute> $attributes
*/
public static function of(PointInTime $time, Str $raw, Set $attributes): self
public static function of(Point $time, Str $raw, Set $attributes): self
{
return new self($time, $raw, $attributes);
}

#[\NoDiscard]
public function time(): PointInTime
public function time(): Point
{
return $this->time;
}
Expand Down
18 changes: 16 additions & 2 deletions tests/LineParser/ApacheAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
LineParser,
Log,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
};
Expand All @@ -24,6 +24,7 @@
use Innmind\Immutable\Str;
use PHPUnit\Framework\Attributes\DataProvider;
use Innmind\BlackBox\PHPUnit\Framework\TestCase;
use Composer\InstalledVersions;

class ApacheAccessTest extends TestCase
{
Expand All @@ -35,6 +36,16 @@ public function testInterface()
#[DataProvider('lines')]
public function testInvokation($line, $client, $user, $time, $method, $path, $protocol, $code, $size)
{
if (\is_array($path)) {
[$v84, $v85] = $path;

if (\str_starts_with(InstalledVersions::getVersion('innmind/url'), '5.0')) {
$path = $v84;
} else {
$path = $v85;
}
}

$parse = ApacheAccess::of(
Clock::live()->switch(static fn($timezones) => $timezones->utc()),
);
Expand Down Expand Up @@ -220,7 +231,10 @@ public static function lines(): array
'-',
'2004-03-08T00:23:12+00:00',
'GET',
'/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore¶m1=1.12¶m2=1.12',
[
'/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore¶m1=1.12¶m2=1.12',
'/twiki/bin/oops/TWiki/AppendixFileSystem?template=oopsmore%C2%B6m1=1.12%C2%B6m2=1.12',
],
'1.1',
'200',
11382,
Expand Down
2 changes: 1 addition & 1 deletion tests/LineParser/MonologTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Log\Attribute\Monolog\Level,
Log\Attribute\Monolog\Message,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
};
Expand Down
8 changes: 4 additions & 4 deletions tests/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Log,
Log\Attribute,
};
use Innmind\TimeContinuum\PointInTime;
use Innmind\Time\Point;
use Innmind\Immutable\{
Set,
Str,
Expand All @@ -19,7 +19,7 @@ class LogTest extends TestCase
public function testInterface()
{
$log = Log::of(
$time = PointInTime::now(),
$time = Point::now(),
$raw = Str::of('foo'),
$attributes = Set::of(Attribute\Attribute::of('bar', 42)),
);
Expand All @@ -34,12 +34,12 @@ public function testInterface()
public function testEquals()
{
$log = Log::of(
PointInTime::now(),
Point::now(),
Str::of('foo'),
Set::of(),
);
$log2 = Log::of(
PointInTime::now(),
Point::now(),
Str::of('bar'),
Set::of(),
);
Expand Down
9 changes: 5 additions & 4 deletions tests/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
Reader,
LineParser\Monolog,
};
use Innmind\TimeContinuum\Clock;
use Innmind\Time\Clock;
use Innmind\Filesystem\{
Adapter\Filesystem,
Adapter,
Name,
};
use Innmind\Url\Path;
Expand All @@ -21,7 +21,8 @@ class ReaderTest extends TestCase
public function testParse()
{
$read = Reader::of(Monolog::of(Clock::live()));
$file = Filesystem::mount(Path::of('fixtures/'))
$file = Adapter::mount(Path::of('fixtures/'))
->unwrap()
->get(Name::of('symfony.log'))
->match(
static fn($file) => $file->content(),
Expand All @@ -31,6 +32,6 @@ public function testParse()
$stream = $read($file);

$this->assertInstanceOf(Sequence::class, $stream);
$this->assertCount(5000, $stream);
$this->assertSame(5000, $stream->size());
}
}