Add ProjectZomboidUserLog (user.txt)

Two row variants: low-level Connection events and player join/disconnect
events. The LINE regex accepts both shapes; analysers route via
CONNECTION (action/index/guid/id) and PLAYER_EVENT (steamid/player/event)
named-group regexes. Detectors: filename match plus content signatures
on either variant.
This commit is contained in:
2026-04-30 20:42:19 +00:00
parent 7b3342b3d2
commit d7c36ffc07
4 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
[29-04-26 18:35:41.512] Connection add index=0 guid=144118788000000001 id=null.
[29-04-26 18:35:42.802] 76561198000000001 "Player1" attempting to join.
[29-04-26 18:35:42.804] 76561198000000001 "Player1" allowed to join.
[29-04-26 18:37:14.645] 76561198000000001 "Player1" attempting to join used queue.
[29-04-26 18:39:23.923] Connection disconnect index=0 guid=144118788000000001 id=76561198000000001.
[29-04-26 18:40:00.100] Connection add index=1 guid=144118788000000002 id=null.
[29-04-26 18:40:01.225] 76561198000000002 "Player2" attempting to join.
[29-04-26 18:40:01.500] 76561198000000002 "Player2" allowed to join.
[29-04-26 18:50:30.010] Connection disconnect index=1 guid=144118788000000002 id=76561198000000002.

View File

@@ -0,0 +1,58 @@
<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Log;
use IndifferentKetchup\Codex\Detective\Detective;
use IndifferentKetchup\Codex\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidUserLog;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\UserPattern;
use PHPUnit\Framework\TestCase;
class ProjectZomboidUserLogTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/user-minimal.txt';
}
public function testParsesEachLineAsAnEntry(): void
{
$log = (new ProjectZomboidUserLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$this->assertCount(9, $log->getEntries());
}
public function testConnectionRegexExtractsAddVariant(): void
{
$line = '[29-04-26 18:35:41.512] Connection add index=0 guid=144118788000000001 id=null.';
$this->assertSame(1, preg_match(UserPattern::CONNECTION, $line, $m));
$this->assertSame('add', $m['action']);
$this->assertSame('null', $m['id']);
}
public function testConnectionRegexExtractsDisconnectVariant(): void
{
$line = '[29-04-26 18:39:23.923] Connection disconnect index=0 guid=144118788000000001 id=76561198000000001.';
$this->assertSame(1, preg_match(UserPattern::CONNECTION, $line, $m));
$this->assertSame('disconnect', $m['action']);
$this->assertSame('76561198000000001', $m['id']);
}
public function testPlayerEventRegexExtracts(): void
{
$line = '[29-04-26 18:35:42.802] 76561198000000001 "Player1" attempting to join.';
$this->assertSame(1, preg_match(UserPattern::PLAYER_EVENT, $line, $m));
$this->assertSame('Player1', $m['player']);
$this->assertSame('attempting to join', $m['event']);
}
public function testDetectiveDispatchesByContent(): void
{
$detective = (new Detective())
->setLogFile(new PathLogFile($this->fixturePath()))
->addPossibleLogClass(ProjectZomboidUserLog::class);
$this->assertInstanceOf(ProjectZomboidUserLog::class, $detective->detect());
}
}