-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set LaunchDarklySdk tag for all Timber events (#178)
- Loading branch information
Showing
18 changed files
with
161 additions
and
102 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...droid-client-sdk/src/androidTest/java/com/launchdarkly/sdk/android/TimberLoggingTest.java
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,56 @@ | ||
package com.launchdarkly.sdk.android; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import timber.log.Timber; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class TimberLoggingTest { | ||
|
||
@Rule | ||
public TimberLoggingRule timberLoggingRule = new TimberLoggingRule(); | ||
|
||
private TestTree testTree; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
testTree = new TestTree(); | ||
Timber.plant(testTree); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
testTree = null; | ||
} | ||
|
||
@Test | ||
public void timberTagIsLaunchDarklySdkForAllEvents() { | ||
LDConfig.log().d("event"); | ||
LDConfig.log().d("event"); | ||
|
||
assertEquals(List.of("LaunchDarklySdk", "LaunchDarklySdk"), testTree.loggedTags); | ||
} | ||
|
||
private static class TestTree extends Timber.Tree { | ||
|
||
final List<String> loggedTags = new ArrayList<String>(); | ||
|
||
@Override | ||
protected void log(int priority, @Nullable String tag, @NonNull String message, @Nullable Throwable t) { | ||
loggedTags.add(tag); | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.