diff --git a/baymax-secrets.example.yaml b/baymax-secrets.example.yaml index 7284110..1048a88 100644 --- a/baymax-secrets.example.yaml +++ b/baymax-secrets.example.yaml @@ -18,6 +18,7 @@ logging: sentry: dsn: "" + logging.enabled: true baymax: discord-token: "" diff --git a/build.gradle b/build.gradle index 348a13b..84b7e59 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,7 @@ dependencies { implementation libs.jda implementation libs.logback implementation libs.sentry + implementation libs.sentry.spring.starter implementation libs.snakeyaml implementation libs.caffeine implementation libs.emojis diff --git a/gradle.lockfile b/gradle.lockfile index 8161500..22ee517 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -27,6 +27,9 @@ com.vdurmont:emoji-java:5.1.1=compileClasspath,productionRuntimeClasspath,runtim io.micrometer:micrometer-commons:1.12.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.micrometer:micrometer-observation:1.12.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.sentry:sentry-logback:7.0.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.sentry:sentry-spring-boot-jakarta:7.0.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.sentry:sentry-spring-boot-starter-jakarta:7.0.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +io.sentry:sentry-spring-jakarta:7.0.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.sentry:sentry:7.0.0=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath jakarta.annotation:jakarta.annotation-api:2.1.1=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.dv8tion:JDA:5.0.0-beta.18=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/settings.gradle b/settings.gradle index 3777902..01e2a5d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -39,6 +39,7 @@ dependencyResolutionManagement { library("jda", "net.dv8tion:JDA:$jdaVersion") library("logback", "ch.qos.logback", "logback-classic").withoutVersion() library("sentry", "io.sentry:sentry-logback:$sentryVersion") + library("sentry-spring-starter", "io.sentry:sentry-spring-boot-starter-jakarta:$sentryVersion") library("snakeyaml", "org.yaml", "snakeyaml").withoutVersion() library("caffeine", "com.github.ben-manes.caffeine", "caffeine").withoutVersion() library("emojis", "com.vdurmont:emoji-java:$emojiVersion") diff --git a/src/main/java/space/npstr/baymax/config/SentryConfiguration.java b/src/main/java/space/npstr/baymax/config/SentryConfiguration.java deleted file mode 100644 index 8824c6a..0000000 --- a/src/main/java/space/npstr/baymax/config/SentryConfiguration.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2018 Dennis Neufeld - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package space.npstr.baymax.config; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.LoggerContext; -import io.sentry.Sentry; -import io.sentry.logback.SentryAppender; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Configuration; -import space.npstr.baymax.config.properties.SentryConfig; -import space.npstr.baymax.info.GitRepoState; - -/** - * Created by napster on 09.05.18. - */ -@Configuration -public class SentryConfiguration { - - private static final Logger log = LoggerFactory.getLogger(SentryConfiguration.class); - - private static final String SENTRY_APPENDER_NAME = "SENTRY"; - - public SentryConfiguration(SentryConfig sentryConfig) { - - String dsn = sentryConfig.getDsn(); - - //noinspection ConstantConditions - if (dsn != null && !dsn.isEmpty()) { - turnOn(dsn); - } else { - turnOff(); - } - - } - - private void turnOn(String dsn) { - log.info("Turning on sentry"); - Sentry.init(options -> { - options.setDsn(dsn); - options.setRelease(GitRepoState.getGitRepositoryState().commitId); - }); - getSentryLogbackAppender().start(); - } - - - private static void turnOff() { - log.warn("Turning off sentry"); - Sentry.close(); - getSentryLogbackAppender().stop(); - } - - //programmatically creates a sentry appender if it doesn't exist yet - private static synchronized SentryAppender getSentryLogbackAppender() { - LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); - ch.qos.logback.classic.Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); - - SentryAppender sentryAppender = (SentryAppender) root.getAppender(SENTRY_APPENDER_NAME); - if (sentryAppender == null) { - sentryAppender = new SentryAppender(); - sentryAppender.setName(SENTRY_APPENDER_NAME); - sentryAppender.setMinimumEventLevel(Level.WARN); - sentryAppender.setContext(loggerContext); - root.addAppender(sentryAppender); - } - return sentryAppender; - } -} diff --git a/src/main/java/space/npstr/baymax/config/properties/SentryConfig.java b/src/main/java/space/npstr/baymax/config/properties/SentryConfig.java deleted file mode 100644 index 4501df7..0000000 --- a/src/main/java/space/npstr/baymax/config/properties/SentryConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2018 Dennis Neufeld - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package space.npstr.baymax.config.properties; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * Created by napster on 05.09.18. - */ -@Component -@ConfigurationProperties("sentry") -public class SentryConfig { - - private String dsn = ""; - - public String getDsn() { - return this.dsn; - } - - public void setDsn(String dsn) { - this.dsn = dsn; - } -} diff --git a/src/main/resources/baymax.yaml b/src/main/resources/baymax.yaml index c03a7a8..330f3e3 100644 --- a/src/main/resources/baymax.yaml +++ b/src/main/resources/baymax.yaml @@ -16,6 +16,12 @@ logging: sentry: dsn: "" + logging.enabled: false + in-app-includes: + - "space.npstr" + - "dev.capybaralabs" + logging: + minimum-event-level: warn baymax: status-type: 1