-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1752 from embrace-io/fix-internal-error-logging
Set internal error logger correctly
- Loading branch information
Showing
5 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ationTest/kotlin/io/embrace/android/embracesdk/testcases/features/InternalErrorLogTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.embrace.android.embracesdk.testcases.features | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import io.embrace.android.embracesdk.fakes.FakeEmbLogger | ||
import io.embrace.android.embracesdk.internal.spans.findAttributeValue | ||
import io.embrace.android.embracesdk.testframework.IntegrationTestRule | ||
import io.embrace.android.embracesdk.testframework.assertions.getLastLog | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
internal class InternalErrorLogTest { | ||
|
||
@Rule | ||
@JvmField | ||
val testRule: IntegrationTestRule = IntegrationTestRule() | ||
|
||
@Test | ||
fun `internal error log delivered`() { | ||
testRule.runTest( | ||
setupAction = { | ||
(overriddenInitModule.logger as FakeEmbLogger).throwOnInternalError = false | ||
}, | ||
testCaseAction = { | ||
recordSession { | ||
embrace.impl.internalInterface.logInternalError("Some error message", null) | ||
} | ||
}, | ||
assertAction = { | ||
with(getSingleLogEnvelope().getLastLog()) { | ||
assertEquals("ERROR", severityText) | ||
assertEquals("", body) | ||
|
||
val attrs = checkNotNull(attributes) | ||
assertEquals("sys.internal", attrs.findAttributeValue("emb.type")) | ||
assertEquals( | ||
"Some error message", | ||
attrs.findAttributeValue("exception.message") | ||
) | ||
assertEquals( | ||
"java.lang.RuntimeException", | ||
attrs.findAttributeValue("exception.type") | ||
) | ||
assertNotNull(attrs.findAttributeValue("log.record.uid")) | ||
assertNotNull(attrs.findAttributeValue("session.id")) | ||
checkNotNull(attrs.findAttributeValue("exception.stacktrace")) | ||
} | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters