@@ -2,6 +2,9 @@ package io.sentry
22
33import io.sentry.SentryOptions.RequestSize
44import io.sentry.logger.ILoggerBatchProcessorFactory
5+ import io.sentry.logger.LoggerApi
6+ import io.sentry.test.createSentryClientMock
7+ import io.sentry.test.createTestScopes
58import io.sentry.util.StringUtils
69import java.io.File
710import java.net.Proxy
@@ -15,8 +18,11 @@ import kotlin.test.assertNotNull
1518import kotlin.test.assertNull
1619import kotlin.test.assertSame
1720import kotlin.test.assertTrue
21+ import org.mockito.kotlin.any
22+ import org.mockito.kotlin.anyOrNull
1823import org.mockito.kotlin.eq
1924import org.mockito.kotlin.mock
25+ import org.mockito.kotlin.never
2026import org.mockito.kotlin.verify
2127
2228class SentryOptionsTest {
@@ -501,6 +507,72 @@ class SentryOptionsTest {
501507 assertTrue(options.metrics.isEnabled)
502508 }
503509
510+ @Test
511+ fun `merging options does not warn when legacy logs configuration is absent` () {
512+ val logger = mock<ILogger >()
513+ val options =
514+ SentryOptions ().also {
515+ it.isDebug = true
516+ it.setLogger(logger)
517+ }
518+
519+ options.merge(ExternalOptions ())
520+
521+ verify(logger, never()).log(eq(SentryLevel .WARNING ), any<String >())
522+ }
523+
524+ @Test
525+ fun `merging options warns when legacy logs configuration is true` () {
526+ val logger = mock<ILogger >()
527+ val options =
528+ SentryOptions ().also {
529+ it.isDebug = true
530+ it.setLogger(logger)
531+ }
532+
533+ options.merge(ExternalOptions ().apply { isEnableLogs = true })
534+
535+ verify(logger)
536+ .log(
537+ SentryLevel .WARNING ,
538+ " The 'logs.enabled' option is no longer supported. Manual Sentry.logger() calls no " +
539+ " longer require it, and automatic logging integrations now require their own opt-ins." ,
540+ * emptyArray(),
541+ )
542+ assertLegacyLogsConfigurationDoesNotDisableCapture(options)
543+ }
544+
545+ @Test
546+ fun `merging options warns when legacy logs configuration is false` () {
547+ val logger = mock<ILogger >()
548+ val options =
549+ SentryOptions ().also {
550+ it.isDebug = true
551+ it.setLogger(logger)
552+ }
553+
554+ options.merge(ExternalOptions ().apply { isEnableLogs = false })
555+
556+ verify(logger)
557+ .log(
558+ SentryLevel .WARNING ,
559+ " The 'logs.enabled' option no longer disables manual Sentry.logger() calls. Automatic " +
560+ " logging integrations remain disabled unless enabled through their own opt-ins." ,
561+ * emptyArray(),
562+ )
563+ assertLegacyLogsConfigurationDoesNotDisableCapture(options)
564+ }
565+
566+ private fun assertLegacyLogsConfigurationDoesNotDisableCapture (options : SentryOptions ) {
567+ options.dsn = " https://key@sentry.io/proj"
568+ val client = createSentryClientMock()
569+ val scopes = createTestScopes(options).apply { bindClient(client) }
570+
571+ LoggerApi (scopes).info(" test log" )
572+
573+ verify(client).captureLog(any(), anyOrNull())
574+ }
575+
504576 @Test
505577 fun `merging options merges and overwrites existing tag values` () {
506578 val externalOptions = ExternalOptions ()
0 commit comments