Permalink
Browse files

Disabled logging for release versions.

  • Loading branch information...
Miggets7 committed Sep 19, 2018
1 parent ec12fc7 commit 1c955e3746d44c264ea90172cab0c9b4bcf86500
Showing with 13 additions and 16 deletions.
  1. +13 −16 console/android/src/main/java/org/openremote/android/MainApplication.java
@@ -3,17 +3,12 @@
import android.Manifest;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.logging.*;
public class MainApplication extends Application {
@@ -23,15 +18,17 @@ public void onCreate() {
super.onCreate();
// Fix and configure JUL
AndroidLoggingHandler.reset(new AndroidLoggingHandler());
if (BuildConfig.DEBUG) {
AndroidLoggingHandler.reset(new AndroidLoggingHandler());
if (Boolean.parseBoolean(getApplicationContext().getString(R.string.DEBUG_LOGGING))) {
java.util.logging.Logger.getLogger("org.openremote").setLevel(Level.FINEST);
if (Boolean.parseBoolean(getApplicationContext().getString(R.string.DEBUG_LOGGING))) {
java.util.logging.Logger.getLogger("org.openremote").setLevel(Level.FINEST);
// Get write permission
String writePermission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
if (ContextCompat.checkSelfPermission(getApplicationContext(), writePermission) == PackageManager.PERMISSION_GRANTED) {
addFileHandler(getApplicationContext());
// Get write permission
String writePermission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
if (ContextCompat.checkSelfPermission(getApplicationContext(), writePermission) == PackageManager.PERMISSION_GRANTED) {
addFileHandler(getApplicationContext());
}
}
}
@@ -61,10 +58,10 @@ static void addFileHandler(Context context) {
// Force scan of first log file as might not show via MTP otherwise
MediaScannerConnection.scanFile(
context,
new String[]{logFilePattern + ".0"},
null,
null);
context,
new String[]{logFilePattern + ".0"},
null,
null);
} catch (Exception e) {
e.printStackTrace();
}

0 comments on commit 1c955e3

Please sign in to comment.