Skip to content

Instantly share code, notes, and snippets.

@marius-m
Created April 22, 2022 08:12
Show Gist options
  • Save marius-m/cce4e82cdfe6d98748a473246521e4eb to your computer and use it in GitHub Desktop.
Save marius-m/cce4e82cdfe6d98748a473246521e4eb to your computer and use it in GitHub Desktop.
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class LogUtils {
@NonNull public static String objPrefix(@Nullable Object obj) {
if (obj != null) {
return String.format(
"[%s@%s]",
obj.getClass().getSimpleName(),
Integer.toHexString(obj.hashCode())
);
}
return "[null@instance]";
}
@NonNull public static String objMessage(@Nullable Object obj, @NonNull String message) {
return String.format("%s: %s", objPrefix(obj), message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment