From a244d7ef9d3068016aace1f331a4fc41fea05665 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 21 Sep 2023 13:23:12 +0200 Subject: [PATCH] Detect velocity snapshot logs --- src/Log/Minecraft/Velocity/VelocityLog.php | 6 +- test/data/Velocity/velocity-snapshot.json | 101 +++++++++++++++++++++ test/data/Velocity/velocity-snapshot.log | 8 ++ test/tests/Logs/AutoLogsTest.php | 10 ++ 4 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 test/data/Velocity/velocity-snapshot.json create mode 100644 test/data/Velocity/velocity-snapshot.log diff --git a/src/Log/Minecraft/Velocity/VelocityLog.php b/src/Log/Minecraft/Velocity/VelocityLog.php index 8664aac0..d680d619 100644 --- a/src/Log/Minecraft/Velocity/VelocityLog.php +++ b/src/Log/Minecraft/Velocity/VelocityLog.php @@ -13,8 +13,8 @@ */ abstract class VelocityLog extends MinecraftLog { - protected static string $pattern = '/^(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\]\:).*$/'; - protected static string $prefixPattern = '(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\]\:) '; + protected static string $pattern = '/^(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\](?: \[[^\]]+\])?\:).*$/'; + protected static string $prefixPattern = '(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\](?: \[[^\]]+\])?\:) '; /** * @return VelocityAnalyser @@ -30,7 +30,7 @@ public static function getDefaultAnalyser(): VelocityAnalyser public static function getDetectors(): array { return [ - (new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'Booting up Velocity [0-9\.]+$/m') + (new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'Booting up Velocity [0-9\.]+/m') ]; } diff --git a/test/data/Velocity/velocity-snapshot.json b/test/data/Velocity/velocity-snapshot.json new file mode 100644 index 00000000..ebc7479a --- /dev/null +++ b/test/data/Velocity/velocity-snapshot.json @@ -0,0 +1,101 @@ +{ + "id": "velocity\/proxy", + "name": "Velocity", + "type": "Proxy Log", + "version": null, + "title": "Velocity Proxy Log", + "entries": [ + { + "level": 6, + "time": null, + "prefix": "[11:17:12] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]:", + "lines": [ + { + "number": 1, + "content": "[11:17:12] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]: Booting up Velocity 3.2.0-SNAPSHOT (git-19abb909-b265)..." + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:12] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]:", + "lines": [ + { + "number": 2, + "content": "[11:17:12] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]: Loading localizations..." + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.network.ConnectionManager]:", + "lines": [ + { + "number": 3, + "content": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.network.ConnectionManager]: Connections will use epoll channels, libdeflate (Linux x86_64) compression, OpenSSL 3.0.x (Linux x86_64) ciphers" + } + ] + }, + { + "level": 4, + "time": null, + "prefix": "[11:17:13] [main\/WARN] [com.velocitypowered.proxy.config.VelocityConfiguration]:", + "lines": [ + { + "number": 4, + "content": "[11:17:13] [main\/WARN] [com.velocitypowered.proxy.config.VelocityConfiguration]: Player info forwarding is disabled! All players will appear to be connecting from the proxy and will have offline-mode UUIDs." + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]:", + "lines": [ + { + "number": 5, + "content": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]: Loading plugins..." + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]:", + "lines": [ + { + "number": 6, + "content": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.VelocityServer]: Loaded 0 plugins" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:13] [Netty epoll Boss #0\/INFO] [com.velocitypowered.proxy.network.ConnectionManager]:", + "lines": [ + { + "number": 7, + "content": "[11:17:13] [Netty epoll Boss #0\/INFO] [com.velocitypowered.proxy.network.ConnectionManager]: Listening on \/0.0.0.0:25577" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.Velocity]:", + "lines": [ + { + "number": 8, + "content": "[11:17:13] [main\/INFO] [com.velocitypowered.proxy.Velocity]: Done (0.7s)!" + } + ] + } + ], + "analysis": { + "problems": [], + "information": [] + } +} \ No newline at end of file diff --git a/test/data/Velocity/velocity-snapshot.log b/test/data/Velocity/velocity-snapshot.log new file mode 100644 index 00000000..9b7e3c1c --- /dev/null +++ b/test/data/Velocity/velocity-snapshot.log @@ -0,0 +1,8 @@ +[11:17:12] [main/INFO] [com.velocitypowered.proxy.VelocityServer]: Booting up Velocity 3.2.0-SNAPSHOT (git-19abb909-b265)... +[11:17:12] [main/INFO] [com.velocitypowered.proxy.VelocityServer]: Loading localizations... +[11:17:13] [main/INFO] [com.velocitypowered.proxy.network.ConnectionManager]: Connections will use epoll channels, libdeflate (Linux x86_64) compression, OpenSSL 3.0.x (Linux x86_64) ciphers +[11:17:13] [main/WARN] [com.velocitypowered.proxy.config.VelocityConfiguration]: Player info forwarding is disabled! All players will appear to be connecting from the proxy and will have offline-mode UUIDs. +[11:17:13] [main/INFO] [com.velocitypowered.proxy.VelocityServer]: Loading plugins... +[11:17:13] [main/INFO] [com.velocitypowered.proxy.VelocityServer]: Loaded 0 plugins +[11:17:13] [Netty epoll Boss #0/INFO] [com.velocitypowered.proxy.network.ConnectionManager]: Listening on /0.0.0.0:25577 +[11:17:13] [main/INFO] [com.velocitypowered.proxy.Velocity]: Done (0.7s)! \ No newline at end of file diff --git a/test/tests/Logs/AutoLogsTest.php b/test/tests/Logs/AutoLogsTest.php index 6456f894..c19c2a87 100644 --- a/test/tests/Logs/AutoLogsTest.php +++ b/test/tests/Logs/AutoLogsTest.php @@ -1274,6 +1274,16 @@ public function test_vanilla_start_1132(): void $this->assertStringEqualsFile($log->getExpectedPath(), $log->getOutput(), $log->getLogPath()); } + /** + * @return void + * @throws Exception + */ + public function test_velocity_snapshot(): void + { + $log = new TestLog('Velocity/velocity-snapshot.log'); + $this->assertStringEqualsFile($log->getExpectedPath(), $log->getOutput(), $log->getLogPath()); + } + /** * @return void * @throws Exception