From: David ‘Bombe’ Roden Date: Sun, 28 Jul 2019 11:17:02 +0000 (+0200) Subject: ✨ Add “show metrics” debug information flag X-Git-Tag: v81^2~173 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a1c8d845054f6adcc6ef98e46e7b578874cc866a;p=Sone.git ✨ Add “show metrics” debug information flag --- diff --git a/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt b/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt index acb0155..3115b87 100644 --- a/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt +++ b/src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt @@ -22,4 +22,7 @@ class DebugInformation { @Volatile var showVersionInformation = false + @Volatile + var showMetrics = false + } diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 8f018f5..6657486 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -67,6 +67,7 @@ open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus: fun getCore(configuration: Configuration, freenetInterface: FreenetInterface, identityManager: IdentityManager, soneDownloader: SoneDownloader, imageInserter: ImageInserter, updateChecker: UpdateChecker, webOfTrustUpdater: WebOfTrustUpdater, eventBus: EventBus, database: Database) = Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database).apply { debugInformation.showVersionInformation = configuration.getBooleanValue("Debug/ShowVersionInformation").getValue(false) + debugInformation.showMetrics = configuration.getBooleanValue("Debug/ShowMetrics").getValue(false) }.also(eventBus::register) } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt index 5ec1ea9..6813253 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt @@ -30,4 +30,9 @@ class DebugInformationTest { assertThat(debugInformation.showVersionInformation, equalTo(false)) } + @Test + fun `new debug information has show metrics set to off`() { + assertThat(debugInformation.showMetrics, equalTo(false)) + } + } diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 526c089..d125769 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -108,6 +108,12 @@ class SoneModuleTest { } @Test + fun `show metrics debug information flag is read from config`() { + File(currentDir, "sone.properties").writeText("Debug/ShowMetrics=true") + assertThat(injector.getInstance().debugInformation.showMetrics, equalTo(true)) + } + + @Test fun `event bus is bound`() { assertThat(injector.getInstance(), notNullValue()) }