import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/** The start time. */
private final long startupTime = System.currentTimeMillis();
- private final DebugInformation debugInformation = new DebugInformation();
+ private final AtomicBoolean debug = new AtomicBoolean(false);
/** The preferences. */
private final Preferences preferences;
}
@Nonnull
- public DebugInformation getDebugInformation() {
- return debugInformation;
+ public boolean getDebug() {
+ return debug.get();
}
/**
pageToadletRegistry.addPage(new EmptyImageTitlePage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new EmptyAlbumTitlePage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new DismissNotificationPage(this, loaders, templateRenderer));
- if (getCore().getDebugInformation().getShowMetrics()) {
+ if (getCore().getDebug()) {
pageToadletRegistry.addPage(new MetricsPage(this, loaders, templateRenderer, metricRegistry));
}
pageToadletRegistry.addPage(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css"));
+++ /dev/null
-/**
- * Sone - DebugInformation.kt - Copyright © 2019 David ‘Bombe’ Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.core
-
-class DebugInformation {
-
- @Volatile
- var showVersionInformation = false
-
- @Volatile
- var showMetrics = false
-
-}
import com.google.inject.name.Names.*
import com.google.inject.spi.*
import freenet.l10n.*
-import net.pterodactylus.sone.core.*
import net.pterodactylus.sone.database.*
import net.pterodactylus.sone.database.memory.*
import net.pterodactylus.sone.freenet.wot.*
})
}
- @Provides
- @Singleton
- 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)
-
}
private fun String.parseVersion(): Version = Version.parse(this)
<div class="inner-menu">
<div>
<a class="author" href="viewSone.html?sone=<%sone.id|html>"><%sone.niceName|html></a>
- (<%= View.Sone.Stats.Posts|l10n 0=sone.posts.size>, <%= View.Sone.Stats.Replies|l10n 0=sone.replies.size><%if ! sone.allImages.size|match value==0>, <%= View.Sone.Stats.Images|l10n 0=sone.allImages.size><%/if><%if core.debugInformation.showVersionInformation>, <% sone.client|html><%/if>)
+ (<%= View.Sone.Stats.Posts|l10n 0=sone.posts.size>, <%= View.Sone.Stats.Replies|l10n 0=sone.replies.size><%if ! sone.allImages.size|match value==0>, <%= View.Sone.Stats.Images|l10n 0=sone.allImages.size><%/if><%if core.debug>, <% sone.client|html><%/if>)
</div>
<div><a href="/WebOfTrust/ShowIdentity?id=<%sone.id|html>">» <% =View.Post.WebOfTrustLink|l10n|html></a></div>
<%foreach sone.albums album>
}
@Test
- fun `core starts without debug flags`() {
+ fun `core starts with debug set to false`() {
val configuration = mock<Configuration>()
val freenetInterface = mock<FreenetInterface>()
val identityManager = mock<IdentityManager>()
val eventBus = mock<EventBus>()
val database = mock<Database>()
val core = Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database)
- assertThat(core.debugInformation.showVersionInformation, equalTo(false))
+ assertThat(core.debug, equalTo(false))
}
}
+++ /dev/null
-/**
- * Sone - DebugInformationTest.kt - Copyright © 2019 David ‘Bombe’ Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.core
-
-import org.hamcrest.MatcherAssert.*
-import org.hamcrest.Matchers.*
-import kotlin.test.*
-
-class DebugInformationTest {
-
- private val debugInformation = DebugInformation()
-
- @Test
- fun `new debug information has show version information set to off`() {
- assertThat(debugInformation.showVersionInformation, equalTo(false))
- }
-
- @Test
- fun `new debug information has show metrics set to off`() {
- assertThat(debugInformation.showMetrics, equalTo(false))
- }
-
-}
}
@Test
- fun `show version information debug information flag is read from config`() {
- File(currentDir, "sone.properties").writeText("Debug/ShowVersionInformation=true")
- assertThat(injector.getInstance<Core>().debugInformation.showVersionInformation, equalTo(true))
- }
-
- @Test
- fun `show metrics debug information flag is read from config`() {
- File(currentDir, "sone.properties").writeText("Debug/ShowMetrics=true")
- assertThat(injector.getInstance<Core>().debugInformation.showMetrics, equalTo(true))
- }
-
- @Test
fun `event bus is bound`() {
assertThat(injector.getInstance<EventBus>(), notNullValue())
}