Merge branch 'pz42x-line-regex'
Some checks failed
Tests / Run tests on PHP v8.4 (push) Failing after 2s
Tests / Run tests on PHP v8.5 (push) Failing after 1s

Fixes DebugServerPattern::LINE so PZ build 42.x logs (which dropped
the per-line `t:` microsecond field) parse with proper level/prefix
attribution. Without the fix every B42 entry fell through as level
INFO and ServerExceptionProblem / ModMissingProblem silently failed
to fire, leaving B42 log views with at most a single
EngineVersionInformation badge and no Problems panel. Backwards
compatible with B41 format; ProjectZomboidServerLogTest now runs
parameterised against both shapes via #[DataProvider].
This commit is contained in:
2026-05-06 13:33:43 +00:00
3 changed files with 49 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ namespace IndifferentKetchup\Codex\Pattern\ProjectZomboid;
*/
class DebugServerPattern
{
public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\]\s+(\w+)\s*:\s+(\S+)\s+f:\d+,\s+t:\d+,\s+st:[\d,]+>\s+.*$/';
public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\]\s+(\w+)\s*:\s+(\S+)\s+f:\d+(?:,\s+t:\d+)?,?\s+st:[\d,]+>\s+.*$/';
public const string VERSION = '/version=(?<version>\S+) (?<hash>[a-f0-9]{40}) (?<date>\d{4}-\d{2}-\d{2}) (?<time>\d{2}:\d{2}:\d{2})/';

View File

@@ -0,0 +1,22 @@
[16-04-26 00:00:42.314] LOG : General f:0 st:48,648,157,434> SLF4J(W): No SLF4J providers were found..
[16-04-26 00:00:42.315] LOG : General f:0 st:48,648,157,492> SLF4J(W): Defaulting to no-operation (NOP) logger implementation.
[16-04-26 00:00:42.407] LOG : General f:0 st:48,648,157,584> version=42.17.0 0000000000000000000000000000000000000000 2026-04-20 14:34:44 (ZB) demo=false.
[16-04-26 00:00:42.407] LOG : General f:0 st:48,648,157,585> revision=0000000000000000000000000000000000000000 date=2026-04-20 time=14:34:44 (ZB).
[16-04-26 00:01:19.080] ERROR: General f:0 st:48,648,194,258> DebugFileWatcher.registerDir> Exception thrown
java.nio.file.NoSuchFileException: /placeholder/config/mods at UnixException.translateToIOException(null:-1).
Stack trace:
java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
java.base/sun.nio.fs.UnixException.asIOException(Unknown Source)
java.base/sun.nio.fs.LinuxWatchService$Poller.implRegister(Unknown Source)
java.base/sun.nio.fs.AbstractPoller.processRequests(Unknown Source)
java.base/sun.nio.fs.LinuxWatchService$Poller.run(Unknown Source)
[16-04-26 00:01:19.131] LOG : Mod f:0 st:48,648,194,309> loading example_mod_alpha.
[16-04-26 00:01:19.142] LOG : Mod f:0 st:48,648,194,320> loading example_mod_beta.
[16-04-26 00:01:19.155] LOG : Mod f:0 st:48,648,194,333> loading example_mod_gamma.
[16-04-26 00:01:19.200] WARN : Mod f:0 st:48,648,194,378> ZomboidFileSystem.loadModAndRequired> required mod "absent_mod" not found.
[16-04-26 00:01:45.937] ERROR: WorldGen f:0 st:48,648,221,115> IsoPropertyType.lookupOrDefaultStr> Exception thrown
zombie.core.properties.IsoPropertyType$IsoPropertyTypeNotFoundException: Property Name not found: ladderW at IsoPropertyType.lookup(IsoPropertyType.java:269). Message: Property Name not found: ladderW
at zombie.core.properties.IsoPropertyType.lookup(IsoPropertyType.java:269)
at zombie.iso.IsoChunkData.PostProcessChunk(IsoChunkData.java:512)
[16-04-26 00:02:00.000] LOG : General f:0 st:48,648,235,178> server initialised.
[16-04-26 00:05:00.000] LOG : General f:0 st:48,648,415,178> shutdown requested.

View File

@@ -6,18 +6,31 @@ use IndifferentKetchup\Codex\Detective\Detective;
use IndifferentKetchup\Codex\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\Level;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidServerLog;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ProjectZomboidServerLogTest extends TestCase
{
private function fixturePath(): string
/**
* Both PZ B41 and B42 line shapes must parse identically. B41 (and the
* fixture used by every analyser test) emits `f:N, t:N, st:N,N,N,N>`;
* B42 (release branch from 2026-04 onward, e.g. build 42.17) drops the
* `t:` microsecond field entirely and tightens whitespace to
* `f:N st:N,N,N,N>`.
*/
public static function fixtureProvider(): array
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/debug-server-minimal.txt';
$base = __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures';
return [
'pz41-format' => [$base . '/debug-server-minimal.txt'],
'pz42-format' => [$base . '/debug-server-42x-minimal.txt'],
];
}
public function testParsesEntriesWithLevelAndPrefix(): void
#[DataProvider('fixtureProvider')]
public function testParsesEntriesWithLevelAndPrefix(string $fixturePath): void
{
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($fixturePath));
$log->parse();
$entries = $log->getEntries();
@@ -29,9 +42,10 @@ class ProjectZomboidServerLogTest extends TestCase
$this->assertNotNull($first->getTime());
}
public function testStackTraceLinesAttachToTriggeringErrorEntry(): void
#[DataProvider('fixtureProvider')]
public function testStackTraceLinesAttachToTriggeringErrorEntry(string $fixturePath): void
{
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($fixturePath));
$log->parse();
$errorEntry = null;
@@ -46,19 +60,21 @@ class ProjectZomboidServerLogTest extends TestCase
$this->assertGreaterThan(1, count($errorEntry->getLines()));
}
public function testWarnLevelMapsCorrectly(): void
#[DataProvider('fixtureProvider')]
public function testWarnLevelMapsCorrectly(string $fixturePath): void
{
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log = (new ProjectZomboidServerLog())->setLogFile(new PathLogFile($fixturePath));
$log->parse();
$warnEntries = array_filter($log->getEntries(), fn($e) => $e->getLevel() === Level::WARNING);
$this->assertNotEmpty($warnEntries);
}
public function testDetectiveDispatchesByContent(): void
#[DataProvider('fixtureProvider')]
public function testDetectiveDispatchesByContent(string $fixturePath): void
{
$detective = (new Detective())
->setLogFile(new PathLogFile($this->fixturePath()))
->setLogFile(new PathLogFile($fixturePath))
->addPossibleLogClass(ProjectZomboidServerLog::class);
$log = $detective->detect();