What logging solutions exist for j2me?
I\'m specifically interested in easily excluding logging for \"release\" version, to have a smaller package & memory foot
If you are using preprocessing and obfuscation with Proguard, then you can have a simple logging class.
public class Log {
public static void debug(final String message) {
//#if !release.build
System.out.println(message);
//#endif
}
}
Or do logging where ever you need to. Now, if release.build property is set to true, this code will be commented out, that will result in an empty method. Proguard will remove all usages of empty method - In effect release build will have all debug messages removed.
Edit:
Thinking about it on library level (I'm working on mapping J2ME library) I have, probably, found a better solution.
public class Log {
private static boolean showDebug;
public static void debug(final String message) {
if (showDebug) {
System.out.println(message);
}
}
public static void setShowDebug(final boolean show) {
showDebug = show;
}
}
This way end developer can enable log levels inside library that he/she is interested in. If nothing will be enabled, all logging code will be removed in end product obfuscation. Sweet :)
/JaanusSiim