Verified Commit 909e946e authored by akwizgran's avatar akwizgran

Enable debug logging for debug and beta builds.

parent 408d9dde
Pipeline #3653 passed with stage
in 9 minutes and 36 seconds
......@@ -37,6 +37,7 @@ import static
import static android.os.Build.VERSION.SDK_INT;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Logger.getLogger;
import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME;
......@@ -82,7 +83,7 @@ public class BriarApplicationImpl extends Application
implements BriarApplication {
private static final Logger LOG =
private final CachingLogHandler logHandler = new CachingLogHandler();
private final BackgroundMonitor backgroundMonitor = new BackgroundMonitor();
......@@ -108,12 +109,16 @@ public class BriarApplicationImpl extends Application
if (IS_DEBUG_BUILD) enableStrictMode();
Logger rootLogger = Logger.getLogger("");
// Remove default log handlers so system log is not used
for (Handler handler : rootLogger.getHandlers()) {
Logger rootLogger = getLogger("");
Handler[] handlers = rootLogger.getHandlers();
// Disable the Android logger for release builds
for (Handler handler : handlers) rootLogger.removeHandler(handler);
// We can't set the level of the Android logger at runtime, so
// raise records to the logger's default level
rootLogger.addHandler(new LevelRaisingHandler(FINE, INFO));
// Restore the default handlers after the level raising handler
for (Handler handler : handlers) rootLogger.addHandler(handler);
rootLogger.setLevel(IS_DEBUG_BUILD || IS_BETA_BUILD ? FINE : INFO);
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
* Log handler that raises all records at or above a given source level to a
* given destination level. This affects the level seen by subsequent handlers.
class LevelRaisingHandler extends Handler {
private final Level dest;
private final int srcInt, destInt;
LevelRaisingHandler(Level src, Level dest) {
this.dest = dest;
srcInt = src.intValue();
destInt = dest.intValue();
if (srcInt > destInt) throw new IllegalArgumentException();
public void publish(LogRecord record) {
int recordInt = record.getLevel().intValue();
if (recordInt >= srcInt && recordInt < destInt) record.setLevel(dest);
public void flush() {
public void close() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment