client: make error logging opt out

This commit is contained in:
Owain van Brakel
2019-11-08 04:36:47 +01:00
parent 894d62998e
commit 7866cc612b
8 changed files with 70 additions and 11 deletions

View File

@@ -52,7 +52,7 @@ dependencies {
}
tasks {
"processTestResources"(ProcessResources::class) {
processTestResources {
val tokens = mapOf(
"rs.version" to ProjectVersions.rsversion.toString(),
"cache.version" to ProjectVersions.cacheversion.toString()

View File

@@ -59,7 +59,7 @@ tasks {
"rs.client" to deobjars.find { it.name.startsWith("runescape-client") }.toString().replace("\\", "/")
)
"processResources"(ProcessResources::class) {
processResources {
inputs.properties(tokens)
from("src/main/resources") {
@@ -69,7 +69,7 @@ tasks {
}
}
"processTestResources"(ProcessResources::class) {
processTestResources {
inputs.properties(tokens)
from("src/test/resources") {

View File

@@ -47,7 +47,7 @@ dependencies {
}
tasks {
"processResources"(ProcessResources::class) {
processResources {
val tokens = mapOf(
"projectver" to ProjectVersions.rlVersion,
"rsver" to ProjectVersions.rsversion.toString(),

View File

@@ -106,18 +106,27 @@ fun formatDate(date: Date?) = with(date ?: Date()) {
SimpleDateFormat("MM-dd-yyyy").format(this)
}
fun launcherVersion(): String {
if (project.hasProperty("releaseBuild")) {
return ProjectVersions.launcherVersion
}
return "-1"
}
tasks {
build {
finalizedBy("shadowJar")
}
"processResources"(ProcessResources::class) {
processResources {
val tokens = mapOf(
"project.version" to ProjectVersions.rlVersion,
"rs.version" to ProjectVersions.rsversion.toString(),
"open.osrs.version" to ProjectVersions.openosrsVersion,
"open.osrs.builddate" to formatDate(Date()),
"launcher.version" to ProjectVersions.launcherVersion
"launcher.version" to launcherVersion()
)
inputs.properties(tokens)
@@ -130,6 +139,7 @@ tasks {
}
jar {
manifest {
attributes(mutableMapOf("Main-Class" to "net.runelite.client.RuneLite"))
}

View File

@@ -27,6 +27,7 @@ package net.runelite.client;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.annotation.Nullable;
public class RuneLiteProperties
{
@@ -40,7 +41,7 @@ public class RuneLiteProperties
private static final String GITHUB_LINK = "runelite.github.link";
private static final String WIKI_LINK = "runelite.wiki.link";
private static final String PATREON_LINK = "runelite.patreon.link";
private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version";
private static final String LAUNCHER_VERSION_PROPERTY = "launcher.version";
private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link";
private static final String BUILDING_LINK = "runelite.wiki.building.link";
private static final String DNS_CHANGE_LINK = "runelite.dnschange.link";
@@ -129,4 +130,11 @@ public class RuneLiteProperties
{
return properties.getProperty(DNS_CHANGE_LINK);
}
@Nullable
public static String getLauncherVersion()
{
String launcherVersion = properties.getProperty(LAUNCHER_VERSION_PROPERTY);
return launcherVersion.equals("-1") ? null : launcherVersion;
}
}

View File

@@ -50,6 +50,29 @@ public interface OpenOSRSConfig extends Config
}
}
@ConfigTitleSection(
keyName = "logTitle",
name = "Error data",
description = "",
position = 1
)
default Title logTitle()
{
return new Title();
}
@ConfigItem(
position = 3,
keyName = "shareLogs",
name = "Anonymous error data",
description = "Share anonymous error data with the OpenOSRS developers",
titleSection = "logTitle"
)
default boolean shareLogs()
{
return true;
}
@ConfigTitleSection(
keyName = "pluginsTitle",
name = "Plugins",

View File

@@ -10,9 +10,12 @@ import io.sentry.Sentry;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.Event;
import net.runelite.client.RuneLiteProperties;
import net.runelite.client.config.OpenOSRSConfig;
@Slf4j
@Singleton
@@ -22,6 +25,9 @@ public class EventBus implements EventBusInterface
private Map<Class<?>, Relay<Object>> subjectList = new HashMap<>();
private Map<Object, CompositeDisposable> subscriptionsMap = new HashMap<>();
@Inject
private OpenOSRSConfig openOSRSConfig;
@NonNull
private <T> Relay<Object> getSubject(Class<T> eventClass)
{
@@ -55,7 +61,12 @@ public class EventBus implements EventBusInterface
.cast(eventClass) // Cast it for easier usage
.subscribe(action, error ->
{
Sentry.capture(error);
log.error("Exception in eventbus", error);
if (RuneLiteProperties.getLauncherVersion() != null && openOSRSConfig.shareLogs())
{
Sentry.capture(error);
}
});
getCompositeDisposable(lifecycle).add(disposable);
@@ -77,7 +88,12 @@ public class EventBus implements EventBusInterface
.doFinally(() -> unregister(lifecycle))
.subscribe(action, error ->
{
Sentry.capture(error);
log.error("Exception in eventbus", error);
if (RuneLiteProperties.getLauncherVersion() != null && openOSRSConfig.shareLogs())
{
Sentry.capture(error);
}
});
getCompositeDisposable(lifecycle).add(disposable);

View File

@@ -33,6 +33,8 @@ dependencies {
implementation(project(":runescape-api"))
}
tasks.withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-source", "7", "-Xlint:-unchecked"))
tasks {
withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-source", "7", "-Xlint:-unchecked"))
}
}