Skip to content

Disable verbose logging in transport-runtime. #3648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private BatchedLogRequest getRequestBody(BackendRequest backendRequest) {

private HttpResponse doSend(HttpRequest request) throws IOException {

Logging.d(LOG_TAG, "Making request to: %s", request.url);
Logging.i(LOG_TAG, "Making request to: %s", request.url);
HttpURLConnection connection = (HttpURLConnection) request.url.openConnection();
connection.setConnectTimeout(CONNECTION_TIME_OUT);
connection.setReadTimeout(readTimeout);
Expand Down Expand Up @@ -315,9 +315,9 @@ private HttpResponse doSend(HttpRequest request) throws IOException {
}

int responseCode = connection.getResponseCode();
Logging.i(LOG_TAG, "Status Code: " + responseCode);
Logging.i(LOG_TAG, "Content-Type: " + connection.getHeaderField("Content-Type"));
Logging.i(LOG_TAG, "Content-Encoding: " + connection.getHeaderField("Content-Encoding"));
Logging.i(LOG_TAG, "Status Code: %d", responseCode);
Logging.d(LOG_TAG, "Content-Type: " + connection.getHeaderField("Content-Type"));
Logging.d(LOG_TAG, "Content-Encoding: " + connection.getHeaderField("Content-Encoding"));

if (responseCode == 302 || responseCode == 301 || responseCode == 307) {
String redirect = connection.getHeaderField("Location");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,51 @@ private static String getTag(String tag) {
}

public static void d(String tag, String message) {
Log.d(getTag(tag), message);
tag = getTag(tag);
if (Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, message);
}
}

public static void d(String tag, String message, Object arg1) {
Log.d(getTag(tag), String.format(message, arg1));
tag = getTag(tag);
if (Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, String.format(message, arg1));
}
}

public static void d(String tag, String message, Object arg1, Object arg2) {
Log.d(getTag(tag), String.format(message, arg1, arg2));
tag = getTag(tag);
if (Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, String.format(message, arg1, arg2));
}
}

public static void d(String tag, String message, Object... args) {
Log.d(getTag(tag), String.format(message, args));
tag = getTag(tag);
if (Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, String.format(message, args));
}
}

public static void i(String tag, String message) {
Log.i(getTag(tag), message);
public static void i(String tag, String message, Object arg1) {
tag = getTag(tag);
if (Log.isLoggable(tag, Log.INFO)) {
Log.i(tag, String.format(message, arg1));
}
}

public static void e(String tag, String message, Throwable e) {
Log.e(getTag(tag), message, e);
tag = getTag(tag);
if (Log.isLoggable(tag, Log.ERROR)) {
Copy link

@gevorg-kopalyan gevorg-kopalyan May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log.isLoggable will produce an error because sometimes it can exceed the limit of 23 characters
From Documentation
IllegalArgumentException is thrown if the tag.length() > 23 for Nougat (7.0) and prior releases (API <= 25), there is no tag limit of concern after this API level.

Log.e(tag, message, e);
}
}

public static void w(String tag, String message, Object arg1) {
Log.w(getTag(tag), String.format(message, arg1));
tag = getTag(tag);
if (Log.isLoggable(tag, Log.WARN)) {
Log.w(tag, String.format(message, arg1));
}
}
}