@@ -8,6 +8,7 @@ import io.sentry.EventProcessor
88import io.sentry.FilterString
99import io.sentry.Hint
1010import io.sentry.IContinuousProfiler
11+ import io.sentry.ILogger
1112import io.sentry.IProfileConverter
1213import io.sentry.IScopes
1314import io.sentry.ITransportFactory
@@ -56,7 +57,9 @@ import org.assertj.core.api.Assertions.assertThat
5657import org.mockito.internal.util.MockUtil.isMock
5758import org.mockito.kotlin.any
5859import org.mockito.kotlin.anyOrNull
60+ import org.mockito.kotlin.eq
5961import org.mockito.kotlin.mock
62+ import org.mockito.kotlin.never
6063import org.mockito.kotlin.verify
6164import org.mockito.kotlin.whenever
6265import org.quartz.JobExecutionContext
@@ -194,6 +197,56 @@ class SentryAutoConfigurationTest {
194197 }
195198 }
196199
200+ @Test
201+ fun `legacy logs property emits no warning when absent` () {
202+ val logger = mock<ILogger >()
203+ dsnEnabledRunner
204+ .withPropertyValues(" sentry.debug=true" )
205+ .withBean(ILogger ::class .java, { logger })
206+ .withUserConfiguration(LoggerConfiguration ::class .java)
207+ .run { verify(logger, never()).log(eq(SentryLevel .WARNING ), any<String >()) }
208+ }
209+
210+ @Test
211+ fun `legacy logs property true emits migration warning` () {
212+ val logger = mock<ILogger >()
213+ dsnEnabledRunner
214+ .withPropertyValues(" sentry.debug=true" , " sentry.logs.enabled=true" )
215+ .withBean(ILogger ::class .java, { logger })
216+ .withUserConfiguration(LoggerConfiguration ::class .java)
217+ .run {
218+ verify(logger)
219+ .log(
220+ SentryLevel .WARNING ,
221+ " The 'sentry.logs.enabled' property is no longer supported. Manual " +
222+ " Sentry.logger() calls no longer require it, and automatic logging " +
223+ " integrations now require their own opt-ins." ,
224+ * emptyArray(),
225+ )
226+ assertThat(it.getBean(SentryProperties ::class .java).logging.isEnableLogs).isFalse()
227+ }
228+ }
229+
230+ @Test
231+ fun `legacy logs property false emits migration warning` () {
232+ val logger = mock<ILogger >()
233+ dsnEnabledRunner
234+ .withPropertyValues(" sentry.debug=true" , " sentry.logs.enabled=false" )
235+ .withBean(ILogger ::class .java, { logger })
236+ .withUserConfiguration(LoggerConfiguration ::class .java)
237+ .run {
238+ verify(logger)
239+ .log(
240+ SentryLevel .WARNING ,
241+ " The 'sentry.logs.enabled' property no longer disables manual Sentry.logger() " +
242+ " calls. Automatic logging integrations remain disabled unless enabled through " +
243+ " their own opt-ins." ,
244+ * emptyArray(),
245+ )
246+ assertThat(it.getBean(SentryProperties ::class .java).logging.isEnableLogs).isFalse()
247+ }
248+ }
249+
197250 @Test
198251 fun `properties are applied to SentryOptions` () {
199252 contextRunner
@@ -1284,6 +1337,13 @@ class SentryAutoConfigurationTest {
12841337 @Bean open fun sentryTransport () = transport
12851338 }
12861339
1340+ @Configuration(proxyBeanMethods = false )
1341+ open class LoggerConfiguration {
1342+ @Bean
1343+ open fun loggerConfiguration (logger : ILogger ) =
1344+ Sentry .OptionsConfiguration <SentryOptions > { it.setLogger(logger) }
1345+ }
1346+
12871347 @Configuration(proxyBeanMethods = false )
12881348 open class NoOpTransportConfiguration {
12891349
0 commit comments