Skip to content

Commit 8edb5f6

Browse files
committed
Shortened prefix and capped concatenated string
1 parent 78e93fb commit 8edb5f6

File tree

1 file changed

+7
-6
lines changed
  • transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/logging

1 file changed

+7
-6
lines changed

transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/logging/Logging.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@
1818
import android.util.Log;
1919

2020
public final class Logging {
21-
private static final String prefix = "TRuntime.";
21+
private static final String LOG_PREFIX = "TRuntime.";
22+
private static final int MAX_LOG_TAG_SIZE_IN_SDK_N = 23;
23+
2224
private Logging() {}
2325

2426
private static String getTag(String tag) {
2527
if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
26-
return concatTag(prefix, tag);
28+
return concatTag(LOG_PREFIX, tag);
2729

28-
return prefix + tag;
30+
return MAX_LOG_TAG_SIZE_IN_SDK_N + tag;
2931
}
3032

3133
private static String concatTag(String prefix, String tag){
3234
String concatText = prefix + tag;
33-
int loggableLimit = 23;
3435

35-
if(concatText.length() > loggableLimit)
36-
concatText = concatText.substring(0, loggableLimit);
36+
if(concatText.length() > MAX_LOG_TAG_SIZE_IN_SDK_N)
37+
concatText = concatText.substring(0, MAX_LOG_TAG_SIZE_IN_SDK_N);
3738

3839
return concatText;
3940
}

0 commit comments

Comments
 (0)