After seeing a lot of questions and answers about how to disable Log.i/e/d calls on release, the answers vary, either use proguard or a log wrapper which checks a bool value. I actually used a log wrapper myself for quite a while but noticed that on some answers there are created instances of StringBuilder even if the log does not get shown in the end.
So, I am trying the following approach:
public class Logger {
static final boolean LOG = true;
public static void printString(String string) {
if (Logger.LOG) {
Log.i("MyApp", string);
}
}
public static void printStrings(String string1, String string2) {
if (Logger.LOG) {
Log.i("MyApp", string1 + " " + string2);
}
}
public static void printObject(Object object) {
if (Logger.LOG) {
Log.i("MyApp", object.toString());
}
}
public static void printException(Exception exception) {
if (Logger.LOG) {
Log.i("MyApp", exception.getLocalizedMessage());
}
}
}
So my question is, does this implementation have the `StringBuilder issue? I realize that is limited to the number of things to log, but can be extended. My main scope is the be able to easily disable the log messages across the app or have more control over them.