client: make error logging opt out (#1953)

client: make error logging opt out
This commit is contained in:
Owain van Brakel
2019-11-08 15:57:46 +01:00
committed by GitHub
33 changed files with 197 additions and 13 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)
{
@@ -53,7 +59,15 @@ public class EventBus implements EventBusInterface
Disposable disposable = getSubject(eventClass)
.filter(Objects::nonNull) // Filter out null objects, better safe than sorry
.cast(eventClass) // Cast it for easier usage
.subscribe(action, Sentry::capture);
.subscribe(action, error ->
{
log.error("Exception in eventbus", error);
if (RuneLiteProperties.getLauncherVersion() != null && openOSRSConfig.shareLogs())
{
Sentry.capture(error);
}
});
getCompositeDisposable(lifecycle).add(disposable);
subscriptionList.put(lifecycle, eventClass);
@@ -72,7 +86,15 @@ public class EventBus implements EventBusInterface
.cast(eventClass) // Cast it for easier usage
.take(takeUntil)
.doFinally(() -> unregister(lifecycle))
.subscribe(action, Sentry::capture);
.subscribe(action, error ->
{
log.error("Exception in eventbus", error);
if (RuneLiteProperties.getLauncherVersion() != null && openOSRSConfig.shareLogs())
{
Sentry.capture(error);
}
});
getCompositeDisposable(lifecycle).add(disposable);
subscriptionList.put(lifecycle, eventClass);

View File

@@ -359,8 +359,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
&& (worldPoint.getY() & (REGION_SIZE - 1)) == objectPoint.getRegionY())
{
// Transform object to get the name which matches against what we've stored
if (getObjectDefinition(object.getId()) != null &&
objectPoint.getName().equals(getObjectDefinition(object.getId()).getName()))
if (objectPoint.getName().equals(getObjectDefinition(object.getId()).getName()))
{
log.debug("Marking object {} due to matching {}", object, objectPoint);
objects.add(object);

View File

@@ -34,6 +34,8 @@ import net.runelite.api.Client;
import net.runelite.api.MessageNode;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.eventbus.EventBus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,6 +57,10 @@ public class ChatMessageManagerTest
@Bind
private ChatColorConfig chatColorConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private ChatMessageManager chatMessageManager;

View File

@@ -56,6 +56,10 @@ public class ConfigManagerTest
@Bind
RuneLiteConfig runeliteConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
ConfigManager manager;

View File

@@ -37,6 +37,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -63,6 +64,10 @@ public class AttackStylesPluginTest
@Bind
AttackStylesConfig attackConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
AttackStylesPlugin attackPlugin;

View File

@@ -35,6 +35,7 @@ import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -61,6 +62,10 @@ public class BankPluginTest
@Bind
private BankConfig bankConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private BankPlugin bankPlugin;

View File

@@ -34,6 +34,7 @@ import net.runelite.api.Client;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
@@ -110,6 +111,10 @@ public class ItemValueSearchTest
@Bind
private ScheduledExecutorService scheduledExecutorService;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -33,6 +33,7 @@ import javax.inject.Inject;
import net.runelite.api.NPC;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.GameTick;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
@@ -50,6 +51,10 @@ public class CerberusPluginTest
@Bind
OverlayManager overlayManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
CerberusPlugin cerberusPlugin;

View File

@@ -35,6 +35,7 @@ import net.runelite.api.Client;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.OpenOSRSConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,6 +68,10 @@ public class ChatCommandsPluginTest
@Bind
ChatCommandsConfig chatCommandsConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
ChatCommandsPlugin chatCommandsPlugin;

View File

@@ -31,6 +31,7 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.client.config.OpenOSRSConfig;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -54,6 +55,10 @@ public class ChatFilterPluginTest
@Bind
private ChatFilterConfig chatFilterConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Mock
private Player localPlayer;

View File

@@ -37,6 +37,7 @@ import net.runelite.api.events.ChatMessage;
import net.runelite.api.util.Text;
import net.runelite.client.Notifier;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.OpenOSRSConfig;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -66,6 +67,10 @@ public class ChatNotificationsPluginTest
@Bind
private Notifier notifier;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private ChatNotificationsPlugin chatNotificationsPlugin;

View File

@@ -34,6 +34,7 @@ import net.runelite.api.GraphicID;
import net.runelite.api.Player;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
@@ -89,6 +90,10 @@ public class CookingPluginTest
@Bind
OverlayManager overlayManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -36,6 +36,7 @@ import net.runelite.api.MessageNode;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.OpenOSRSConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,6 +59,10 @@ public class EmojiPluginTest
@Bind
private ChatMessageManager chatMessageManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private EmojiPlugin emojiPlugin;

View File

@@ -38,6 +38,7 @@ import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.widgets.Widget;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.http.api.examine.ExamineClient;
import org.junit.Before;
@@ -78,6 +79,10 @@ public class ExaminePluginTest
@Bind
ScheduledExecutorService scheduledExecutorService;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -46,6 +46,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged;
import net.runelite.client.Notifier;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.SoundManager;
import org.junit.Before;
import org.junit.Test;
@@ -81,6 +82,10 @@ public class IdleNotifierPluginTest
@Bind
private Notifier notifier;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private IdleNotifierPlugin plugin;

View File

@@ -38,6 +38,7 @@ import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.Notifier;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.ui.overlay.OverlayManager;
import org.junit.Before;
@@ -88,6 +89,10 @@ public class ItemChargePluginTest
@Bind
private ItemChargeConfig config;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private ItemChargePlugin itemChargePlugin;

View File

@@ -35,6 +35,7 @@ import net.runelite.api.Client;
import net.runelite.api.Item;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemReclaimCost;
import static net.runelite.client.plugins.itemskeptondeath.ItemsKeptOnDeathPlugin.DeathItems;
@@ -60,6 +61,10 @@ public class ItemsKeptOnDeathPluginTest
@Bind
private ItemManager itemManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private ItemsKeptOnDeathPlugin plugin;

View File

@@ -41,6 +41,7 @@ import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.Notifier;
import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.config.RuneLiteConfig;
import org.junit.Before;
import org.junit.Test;
@@ -102,6 +103,10 @@ public class MotherlodePluginTest
@Bind
private Notifier notifier;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -32,6 +32,7 @@ import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.client.config.OpenOSRSConfig;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -54,6 +55,10 @@ public class NpcIndicatorsPluginTest
@Bind
private NpcIndicatorsConfig npcIndicatorsConfig;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
private NpcIndicatorsPlugin npcIndicatorsPlugin;

View File

@@ -41,6 +41,7 @@ import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID;
import static net.runelite.api.widgets.WidgetInfo.DIALOG_SPRITE_TEXT;
import static net.runelite.api.widgets.WidgetInfo.LEVEL_UP_LEVEL;
import net.runelite.client.Notifier;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.DrawManager;
@@ -97,6 +98,10 @@ public class ScreenshotPluginTest
@Bind
ScheduledExecutorService service;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -49,6 +49,7 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier;
import net.runelite.client.chat.ChatCommandManager;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
@@ -149,6 +150,10 @@ public class SlayerPluginTest
@Bind
SlayerTaskPanel panel;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -30,6 +30,7 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
import javax.inject.Inject;
import net.runelite.api.ChatMessageType;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -60,6 +61,10 @@ public class SmeltingPluginTest
@Bind
OverlayManager overlayManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -33,6 +33,7 @@ import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.WorldType;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.infobox.InfoBox;
@@ -77,6 +78,10 @@ public class TimersPluginTest
@Bind
private InfoBoxManager infoBoxManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -31,6 +31,7 @@ import java.util.TimeZone;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.OpenOSRSConfig;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -50,6 +51,10 @@ public class TimestampPluginTest
@Bind
TimestampConfig config;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Inject
TimestampPlugin plugin;

View File

@@ -34,6 +34,7 @@ import net.runelite.api.Varbits;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.Notifier;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.ui.overlay.OverlayManager;
import org.junit.Before;
import org.junit.Test;
@@ -74,6 +75,10 @@ public class WintertodtPluginTest
@Bind
Client client;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

View File

@@ -35,6 +35,7 @@ import net.runelite.api.Skill;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.StatChanged;
import net.runelite.client.config.OpenOSRSConfig;
import net.runelite.client.game.NPCManager;
import net.runelite.client.game.SkillIconManager;
import net.runelite.client.ui.ClientToolbar;
@@ -78,6 +79,10 @@ public class XpTrackerPluginTest
@Bind
private OverlayManager overlayManager;
@Mock
@Bind
private OpenOSRSConfig openOSRSConfig;
@Before
public void before()
{

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"))
}
}