@@ -29,7 +29,7 @@ import org.mockito.kotlin.verify
2929class ManifestMetadataReaderTest {
3030 private class Fixture {
3131 val logger = mock<ILogger >()
32- val options = SentryAndroidOptions ().apply { setLogger(logger) }
32+ val options = SentryAndroidOptions ().apply { setLogger(this @Fixture. logger) }
3333 val buildInfoProvider = mock<BuildInfoProvider >()
3434
3535 fun getContext (metaData : Bundle = Bundle ()): Context =
@@ -1943,6 +1943,64 @@ class ManifestMetadataReaderTest {
19431943 assertTrue(fixture.options.inAppExcludes.isEmpty())
19441944 }
19451945
1946+ @Test
1947+ fun `applyMetadata does not warn when legacy logs enabled metadata is absent` () {
1948+ fixture.options.isDebug = true
1949+ val context = fixture.getContext()
1950+
1951+ ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1952+
1953+ verify(fixture.logger, never()).log(eq(SentryLevel .WARNING ), any<String >())
1954+ }
1955+
1956+ @Test
1957+ fun `applyMetadata warns when legacy logs enabled metadata is true` () {
1958+ val bundle =
1959+ bundleOf(
1960+ ManifestMetadataReader .DEBUG to true ,
1961+ ManifestMetadataReader .ENABLE_LOGS to true ,
1962+ )
1963+ val context = fixture.getContext(metaData = bundle)
1964+
1965+ ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1966+
1967+ verify(fixture.logger)
1968+ .log(
1969+ SentryLevel .WARNING ,
1970+ " The Android manifest option 'io.sentry.logs.enabled' is no longer supported. " +
1971+ " Manual Sentry.logger() calls no longer require it, and automatic logging " +
1972+ " integrations now require their own opt-ins." ,
1973+ * emptyArray(),
1974+ )
1975+ assertThat(fixture.options.isEnableTimberLogs).isFalse()
1976+ assertThat(fixture.options.isEnableLogcatLogs).isFalse()
1977+ }
1978+
1979+ @Test
1980+ fun `applyMetadata warns when legacy logs enabled metadata is false` () {
1981+ fixture.options.isEnableTimberLogs = true
1982+ fixture.options.isEnableLogcatLogs = true
1983+ val bundle =
1984+ bundleOf(
1985+ ManifestMetadataReader .DEBUG to true ,
1986+ ManifestMetadataReader .ENABLE_LOGS to false ,
1987+ )
1988+ val context = fixture.getContext(metaData = bundle)
1989+
1990+ ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
1991+
1992+ verify(fixture.logger)
1993+ .log(
1994+ SentryLevel .WARNING ,
1995+ " The Android manifest option 'io.sentry.logs.enabled' no longer disables manual " +
1996+ " Sentry.logger() calls. Automatic logging integrations remain disabled unless " +
1997+ " enabled through their own opt-ins." ,
1998+ * emptyArray(),
1999+ )
2000+ assertThat(fixture.options.isEnableTimberLogs).isTrue()
2001+ assertThat(fixture.options.isEnableLogcatLogs).isTrue()
2002+ }
2003+
19462004 @Test
19472005 fun `applyMetadata keeps Timber logs disabled if not found` () {
19482006 val context = fixture.getContext()
0 commit comments