Skip to content
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
Next Next commit
Make logging faster on startup
  • Loading branch information
romtsn committed Oct 15, 2024
commit 8972fdba5208ddb07a15c26b7f15b1ee590acf2f
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public void log(
final @NotNull SentryLevel level,
final @NotNull String message,
final @Nullable Object... args) {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
if (args == null || args.length == 0) {
Log.println(toLogcatLevel(level), tag, message);
} else {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
}
}

@SuppressWarnings("AnnotateFormatMethod")
Expand All @@ -36,7 +40,11 @@ public void log(
final @Nullable Throwable throwable,
final @NotNull String message,
final @Nullable Object... args) {
log(level, String.format(message, args), throwable);
if (args == null || args.length == 0) {
log(level, message, throwable);
} else {
log(level, String.format(message, args), throwable);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private static boolean readBool(
final @NotNull String key,
final boolean defaultValue) {
final boolean value = metadata.getBoolean(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -450,10 +450,10 @@ private static boolean readBool(
if (metadata.getSerializable(key) != null) {
final boolean nonNullDefault = defaultValue == null ? false : true;
final boolean bool = metadata.getBoolean(key, nonNullDefault);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, bool);
logger.log(SentryLevel.DEBUG, key + " read: " + bool);
return bool;
} else {
logger.log(SentryLevel.DEBUG, "%s used default %s", key, defaultValue);
logger.log(SentryLevel.DEBUG, key + " used default " + defaultValue);
return defaultValue;
}
}
Expand All @@ -464,7 +464,7 @@ private static boolean readBool(
final @NotNull String key,
final @Nullable String defaultValue) {
final String value = metadata.getString(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -474,14 +474,14 @@ private static boolean readBool(
final @NotNull String key,
final @NotNull String defaultValue) {
final String value = metadata.getString(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

private static @Nullable List<String> readList(
final @NotNull Bundle metadata, final @NotNull ILogger logger, final @NotNull String key) {
final String value = metadata.getString(key);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
if (value != null) {
return Arrays.asList(value.split(",", -1));
} else {
Expand All @@ -493,7 +493,7 @@ private static boolean readBool(
final @NotNull Bundle metadata, final @NotNull ILogger logger, final @NotNull String key) {
// manifest meta-data only reads float
final Double value = ((Float) metadata.getFloat(key, -1)).doubleValue();
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -504,7 +504,7 @@ private static long readLong(
final long defaultValue) {
// manifest meta-data only reads int if the value is not big enough
final long value = metadata.getInt(key, (int) defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -524,7 +524,6 @@ static boolean isAutoInit(final @NotNull Context context, final @NotNull ILogger
if (metadata != null) {
autoInit = readBool(metadata, logger, AUTO_INIT, true);
}
logger.log(SentryLevel.INFO, "Retrieving auto-init from AndroidManifest.xml");
} catch (Throwable e) {
logger.log(SentryLevel.ERROR, "Failed to read auto-init from android manifest metadata.", e);
}
Expand Down