63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace IndifferentKetchup\Codex\Log\ProjectZomboid;
|
|
|
|
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
|
|
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
|
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\EngineVersionInformation;
|
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ModLoadInformation;
|
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ModMissingProblem;
|
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\ServerExceptionProblem;
|
|
use IndifferentKetchup\Codex\Detective\FilenameDetector;
|
|
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
|
|
use IndifferentKetchup\Codex\Parser\ParserInterface;
|
|
use IndifferentKetchup\Codex\Parser\PatternParser;
|
|
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\DebugServerPattern;
|
|
|
|
/**
|
|
* Project Zomboid engine debug log (DebugLog-server.txt).
|
|
*
|
|
* Multi-line format: ERROR entries are followed by tab-indented stack trace
|
|
* frames. PatternParser handles continuation by appending non-matching lines
|
|
* to the most recent Entry, which is exactly the behaviour we need.
|
|
*/
|
|
class ProjectZomboidServerLog extends ProjectZomboidLog
|
|
{
|
|
public static function getDefaultParser(): ParserInterface
|
|
{
|
|
return static::makePatternParser(
|
|
DebugServerPattern::LINE,
|
|
[PatternParser::TIME, PatternParser::LEVEL, PatternParser::PREFIX]
|
|
);
|
|
}
|
|
|
|
public static function getDefaultAnalyser(): AnalyserInterface
|
|
{
|
|
return (new PatternAnalyser())
|
|
->addPossibleInsightClass(EngineVersionInformation::class)
|
|
->addPossibleInsightClass(ModLoadInformation::class)
|
|
->addPossibleInsightClass(ModMissingProblem::class)
|
|
->addPossibleInsightClass(ServerExceptionProblem::class);
|
|
}
|
|
|
|
public static function getDetectors(): array
|
|
{
|
|
return [
|
|
(new FilenameDetector())
|
|
->setPattern('/DebugLog-server\.txt$/')
|
|
->setWeight(0.95),
|
|
(new WeightedSinglePatternDetector())
|
|
->setPattern('/version=\d+\.\d+\.\d+ [a-f0-9]{40}/')
|
|
->setWeight(0.95),
|
|
(new WeightedSinglePatternDetector())
|
|
->setPattern('/^\[\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\] (?:LOG|WARN|ERROR):\s+\w+\s+f:\d+, t:\d+, st:[\d,]+>/m')
|
|
->setWeight(0.80),
|
|
];
|
|
}
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return "Project Zomboid Debug Server Log";
|
|
}
|
|
}
|