Skip to content

Commit ae6298b

Browse files
authored
Shortened prefix and capped concatenated string (#3728)
* Shortened prefix and capped concatenated string
1 parent 269b64b commit ae6298b

File tree

1 file changed

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

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,28 @@
1414

1515
package com.google.android.datatransport.runtime.logging;
1616

17+
import android.os.Build;
1718
import android.util.Log;
1819

1920
public final class Logging {
21+
private static final String LOG_PREFIX = "TRuntime.";
22+
private static final int MAX_LOG_TAG_SIZE_IN_SDK_N = 23;
23+
2024
private Logging() {}
2125

2226
private static String getTag(String tag) {
23-
return "TransportRuntime." + tag;
27+
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return concatTag(LOG_PREFIX, tag);
28+
29+
return LOG_PREFIX + tag;
30+
}
31+
32+
private static String concatTag(String prefix, String tag) {
33+
String concatText = prefix + tag;
34+
35+
if (concatText.length() > MAX_LOG_TAG_SIZE_IN_SDK_N)
36+
concatText = concatText.substring(0, MAX_LOG_TAG_SIZE_IN_SDK_N);
37+
38+
return concatText;
2439
}
2540

2641
public static void d(String tag, String message) {

0 commit comments

Comments
 (0)