Example usage for android.util Log DEBUG

List of usage examples for android.util Log DEBUG

Introduction

In this page you can find the example usage for android.util Log DEBUG.

Prototype

int DEBUG

To view the source code for android.util Log DEBUG.

Click Source Link

Document

Priority constant for the println method; use Log.d.

Usage

From source file:at.bitfire.davdroid.App.java

public void reinitLogger() {
    // don't use Android default logging, we have our own handlers
    log.setUseParentHandlers(false);//from   w  w  w.j  a v  a2s . c om

    @Cleanup
    ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(this);
    Settings settings = new Settings(dbHelper.getReadableDatabase());

    boolean logToFile = settings.getBoolean(LOG_TO_EXTERNAL_STORAGE, false),
            logVerbose = logToFile || Log.isLoggable(log.getName(), Log.DEBUG);

    // set logging level according to preferences
    log.setLevel(logVerbose ? Level.ALL : Level.INFO);

    // remove all handlers
    for (Handler handler : log.getHandlers())
        log.removeHandler(handler);

    // add logcat handler
    log.addHandler(LogcatHandler.INSTANCE);

    NotificationManagerCompat nm = NotificationManagerCompat.from(this);
    // log to external file according to preferences
    if (logToFile) {
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
        builder.setSmallIcon(R.drawable.ic_sd_storage_light).setLargeIcon(getLauncherBitmap(this))
                .setContentTitle(getString(R.string.logging_davdroid_file_logging)).setLocalOnly(true);

        File dir = getExternalFilesDir(null);
        if (dir != null)
            try {
                String fileName = new File(dir, "davdroid-" + android.os.Process.myPid() + "-"
                        + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + ".txt")
                                .toString();
                log.info("Logging to " + fileName);

                FileHandler fileHandler = new FileHandler(fileName);
                fileHandler.setFormatter(PlainTextFormatter.DEFAULT);
                log.addHandler(fileHandler);
                builder.setContentText(dir.getPath())
                        .setSubText(getString(R.string.logging_to_external_storage_warning))
                        .setCategory(NotificationCompat.CATEGORY_STATUS)
                        .setPriority(NotificationCompat.PRIORITY_HIGH)
                        .setStyle(new NotificationCompat.BigTextStyle()
                                .bigText(getString(R.string.logging_to_external_storage, dir.getPath())))
                        .setOngoing(true);

            } catch (IOException e) {
                log.log(Level.SEVERE, "Couldn't create external log file", e);

                builder.setContentText(getString(R.string.logging_couldnt_create_file, e.getLocalizedMessage()))
                        .setCategory(NotificationCompat.CATEGORY_ERROR);
            }
        else
            builder.setContentText(getString(R.string.logging_no_external_storage));

        nm.notify(Constants.NOTIFICATION_EXTERNAL_FILE_LOGGING, builder.build());
    } else
        nm.cancel(Constants.NOTIFICATION_EXTERNAL_FILE_LOGGING);
}

From source file:com.samsung.multiwindow.MultiWindow.java

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {

    if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
        Log.d(TAG, "Initialize multiwindow");
    }//from ww w . j  a  v  a2s  .co  m
    super.initialize(cordova, webView);
    String packageName = cordova.getActivity().getPackageName();
    PackageManager pm = cordova.getActivity().getPackageManager();
    ApplicationInfo ai = null;
    try {
        ai = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            pluginMetadata = ai.metaData.getBoolean(META_DATA);
        }
    } catch (NameNotFoundException e) {
        Log.e("MultiWindow", e.getMessage());
    }
}

From source file:org.openschedule.api.impl.EventTemplate.java

public List<Comment> getEventComments(String shortName) {
    Log.v(TAG, "getEventComments : enter");

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "getEventComments : shortName=" + shortName);
    }//www.  j  a v a2  s  . c  o m

    Log.v(TAG, "getEventComments : exit");
    return restTemplate.getForObject(buildUri("public/" + shortName + "/comments"), CommentList.class);
}

From source file:com.scvngr.levelup.core.util.LogManager.java

/**
 * Log a message./*from   ww w  .j  a  v  a2s  .  com*/
 *
 * @param msg message to log.
 * @param err an exception that occurred, whose trace will be printed with the log message.
 */
public static void d(@NonNull final String msg, @NonNull final Throwable err) {
    logMessage(Log.DEBUG, msg, null, err);
}

From source file:com.cbsb.ftpserv.Util.java

public static void deletedFileNotify(String path) {
    // This might not work, I couldn't find an API call for this.
    if (Defaults.do_mediascanner_notify) {
        myLog.l(Log.DEBUG, "Notifying others about deleted file: " + path);
        new MediaScannerNotifier(Globals.getContext(), path);
    }//from w w w.  ja va  2 s.co  m
}

From source file:com.google.android.apps.forscience.whistlepunk.PictureUtils.java

private static String capturePictureLabel(Context context, IStartable startable) {
    // Starts a picture intent.
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(context.getPackageManager()) != null) {
        File photoFile = null;/*from   ww w . j a  v  a 2 s.co m*/
        try {
            photoFile = PictureUtils.createImageFile(
                    AppSingleton.getInstance(context).getSensorEnvironment().getDefaultClock().getNow());
        } catch (IOException ex) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, ex.getMessage());
            }
        }
        if (photoFile != null) {
            Uri photoUri = FileProvider.getUriForFile(context, context.getPackageName(), photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                // Needed to avoid security exception on KitKat.
                takePictureIntent.setClipData(ClipData.newRawUri(null, photoUri));
            }
            takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            String pictureLabelPath = "file:" + photoFile.getAbsoluteFile();
            startable.startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            return pictureLabelPath;
        }
    }
    return null;
}

From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java

/**
 * @see SearchRecentSuggestionsProvider#onCreate()
 *//* ww w .  ja  va 2s .c om*/
public boolean onCreate() {
    final String METHOD_NAME = CLASS_NAME + ".onCreate()";
    boolean loggingEnabled = Log.isLoggable(LOG_TAG, Log.DEBUG);
    if (loggingEnabled) {
        Log.d(METHOD_NAME, "ENTRY");
    }

    setupSuggestions(AUTHORITY, MODE);

    if (loggingEnabled) {
        Log.d(METHOD_NAME, "EXIT");
    }

    return super.onCreate();
}

From source file:cm.confide.ex.chips.RecipientAlternatesAdapter.java

/**
 * Get a HashMap of address to RecipientEntry that contains all contact
 * information for a contact with the provided address, if one exists. This
 * may block the UI, so run it in an async task.
 *
 * @param context Context./*from w w w  .  ja  v a 2s. c  o m*/
 * @param inAddresses Array of addresses on which to perform the lookup.
 * @param callback RecipientMatchCallback called when a match or matches are found.
 * @return HashMap<String,RecipientEntry>
 */
public static void getMatchingRecipients(Context context, BaseRecipientAdapter adapter,
        ArrayList<String> inAddresses, int addressType, Account account, RecipientMatchCallback callback) {
    Queries.Query query;
    if (addressType == QUERY_TYPE_EMAIL) {
        query = Queries.EMAIL;
    } else {
        query = Queries.PHONE;
    }
    int addressesSize = Math.min(MAX_LOOKUPS, inAddresses.size());
    HashSet<String> addresses = new HashSet<String>();
    StringBuilder bindString = new StringBuilder();
    // Create the "?" string and set up arguments.
    for (int i = 0; i < addressesSize; i++) {
        Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase());
        addresses.add(tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i));
        bindString.append("?");
        if (i < addressesSize - 1) {
            bindString.append(",");
        }
    }

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Doing reverse lookup for " + addresses.toString());
    }

    String[] addressArray = new String[addresses.size()];
    addresses.toArray(addressArray);
    HashMap<String, RecipientEntry> recipientEntries = null;
    Cursor c = null;

    try {
        c = context.getContentResolver().query(query.getContentUri(), query.getProjection(),
                query.getProjection()[Queries.Query.DESTINATION] + " IN (" + bindString.toString() + ")",
                addressArray, null);
        recipientEntries = processContactEntries(c);
        callback.matchesFound(recipientEntries);
    } finally {
        if (c != null) {
            c.close();
        }
    }
    // See if any entries did not resolve; if so, we need to check other
    // directories
    final Set<String> matchesNotFound = new HashSet<String>();
    if (recipientEntries.size() < addresses.size()) {
        final List<DirectorySearchParams> paramsList;
        Cursor directoryCursor = null;
        try {
            directoryCursor = context.getContentResolver().query(DirectoryListQuery.URI,
                    DirectoryListQuery.PROJECTION, null, null, null);
            if (directoryCursor == null) {
                paramsList = null;
            } else {
                paramsList = BaseRecipientAdapter.setupOtherDirectories(context, directoryCursor, account);
            }
        } finally {
            if (directoryCursor != null) {
                directoryCursor.close();
            }
        }
        // Run a directory query for each unmatched recipient.
        HashSet<String> unresolvedAddresses = new HashSet<String>();
        for (String address : addresses) {
            if (!recipientEntries.containsKey(address)) {
                unresolvedAddresses.add(address);
            }
        }

        matchesNotFound.addAll(unresolvedAddresses);

        if (paramsList != null) {
            Cursor directoryContactsCursor = null;
            for (String unresolvedAddress : unresolvedAddresses) {
                for (int i = 0; i < paramsList.size(); i++) {
                    try {
                        directoryContactsCursor = doQuery(unresolvedAddress, 1, paramsList.get(i).directoryId,
                                account, context.getContentResolver(), query);
                    } finally {
                        if (directoryContactsCursor != null && directoryContactsCursor.getCount() == 0) {
                            directoryContactsCursor.close();
                            directoryContactsCursor = null;
                        } else {
                            break;
                        }
                    }
                }
                if (directoryContactsCursor != null) {
                    try {
                        final Map<String, RecipientEntry> entries = processContactEntries(
                                directoryContactsCursor);

                        for (final String address : entries.keySet()) {
                            matchesNotFound.remove(address);
                        }

                        callback.matchesFound(entries);
                    } finally {
                        directoryContactsCursor.close();
                    }
                }
            }
        }
    }

    // If no matches found in contact provider or the directories, try the extension
    // matcher.
    // todo (aalbert): This whole method needs to be in the adapter?
    if (adapter != null) {
        final Map<String, RecipientEntry> entries = adapter.getMatchingRecipients(matchesNotFound);
        if (entries != null && entries.size() > 0) {
            callback.matchesFound(entries);
            for (final String address : entries.keySet()) {
                matchesNotFound.remove(address);
            }
        }
    }
    callback.matchesNotFound(matchesNotFound);
}

From source file:com.joptimizer.optimizers.NewtonLEConstrainedISP.java

@Override
public int optimize() throws Exception {
    Log.d(MainActivity.JOPTIMIZER_LOGTAG, "optimize");
    OptimizationResponse response = new OptimizationResponse();

    //checking responsibility
    if (getFi() != null) {
        // forward to the chain
        return forwardOptimizationRequest();
    }//from w w w  .  j a va2  s. c o  m

    long tStart = System.currentTimeMillis();
    DoubleMatrix1D X0 = getInitialPoint();
    if (X0 == null) {
        if (getA() != null) {
            X0 = F1.make(findEqFeasiblePoint(getA().toArray(), getB().toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG,
                    "Switch to the linear equality feasible starting point Newton algorithm ");
            NewtonLEConstrainedFSP opt = new NewtonLEConstrainedFSP();
            OptimizationRequest req = getOptimizationRequest();
            req.setInitialPoint(X0.toArray());
            opt.setOptimizationRequest(req);
            int retcode = opt.optimize();
            OptimizationResponse resp = opt.getOptimizationResponse();
            setOptimizationResponse(resp);
            return retcode;
        } else {
            X0 = F1.make(getDim());
        }
    }
    DoubleMatrix1D V0 = (getA() != null) ? F1.make(getA().rows()) : F1.make(0);
    if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) {
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0:  " + ArrayUtils.toString(X0.toArray()));
    }

    DoubleMatrix1D X = X0;
    DoubleMatrix1D V = V0;
    double F0X;
    DoubleMatrix1D gradX = null;
    DoubleMatrix2D hessX = null;
    DoubleMatrix1D rDualXV = null;
    DoubleMatrix1D rPriX = null;
    double previousF0X = Double.NaN;
    double previousRPriXNorm = Double.NaN;
    double previousRXVNorm = Double.NaN;
    int iteration = 0;
    while (true) {
        iteration++;
        F0X = getF0(X);
        if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) {
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "iteration " + iteration);
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X=" + ArrayUtils.toString(X.toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V=" + ArrayUtils.toString(V.toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f(X)=" + F0X);
        }

        //         if(!Double.isNaN(previousF0X)){
        //            if (previousF0X < F0X) {
        //               throw new Exception("critical minimization problem");
        //            }
        //         }
        //         previousF0X = F0X;

        // custom exit condition
        if (checkCustomExitConditions(X)) {
            response.setReturnCode(OptimizationResponse.SUCCESS);
            break;
        }

        gradX = getGradF0(X);
        hessX = getHessF0(X);
        rDualXV = rDual(X, V, gradX);
        rPriX = rPri(X);

        // exit condition
        double rPriXNorm = Math.sqrt(ALG.norm2(rPriX));
        double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV));
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriXNorm : " + rPriXNorm);
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rDualXVNorm: " + rDualXVNorm);
        double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rDualXVNorm, 2));
        if (rPriXNorm <= getTolerance() && rXVNorm <= getTolerance()) {
            response.setReturnCode(OptimizationResponse.SUCCESS);
            break;
        }

        // Newton step and decrement
        if (this.kktSolver == null) {
            this.kktSolver = new BasicKKTSolver();
        }
        if (isCheckKKTSolutionAccuracy()) {
            kktSolver.setCheckKKTSolutionAccuracy(isCheckKKTSolutionAccuracy());
            kktSolver.setToleranceKKT(getToleranceKKT());
        }
        kktSolver.setHMatrix(hessX.toArray());
        kktSolver.setGVector(rDualXV.toArray());
        if (getA() != null) {
            kktSolver.setAMatrix(getA().toArray());
            kktSolver.setATMatrix(getAT().toArray());
            kktSolver.setHVector(rPriX.toArray());
        }
        double[][] sol = kktSolver.solve();
        DoubleMatrix1D stepX = F1.make(sol[0]);
        DoubleMatrix1D stepV = (sol[1] != null) ? F1.make(sol[1]) : F1.make(0);
        if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) {
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepX: " + ArrayUtils.toString(stepX.toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepV: " + ArrayUtils.toString(stepV.toArray()));
        }

        //         // exit condition
        //         double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); 
        //         double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV));
        //         Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPriXNorm : "+rPriXNorm);
        //         Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDualXVNorm: "+rDualXVNorm);
        //         double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2)+ Math.pow(rDualXVNorm, 2));
        //         if (rPriXNorm <= getTolerance() && rXVNorm <= getTolerance()) {
        //            response.setReturnCode(OptimizationResponse.SUCCESS);
        //            break;
        //         }

        // iteration limit condition
        if (iteration == getMaxIteration()) {
            response.setReturnCode(OptimizationResponse.WARN);
            Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached");
            break;
        }

        // progress conditions
        if (isCheckProgressConditions()) {
            if (!Double.isNaN(previousRPriXNorm) && !Double.isNaN(previousRXVNorm)) {
                if ((previousRPriXNorm <= rPriXNorm && rPriXNorm >= getTolerance())
                        || (previousRXVNorm <= rXVNorm && rXVNorm >= getTolerance())) {
                    Log.w(MainActivity.JOPTIMIZER_LOGTAG,
                            "No progress achieved, exit iterations loop without desired accuracy");
                    response.setReturnCode(OptimizationResponse.WARN);
                    break;

                }
            }
        }
        previousRPriXNorm = rPriXNorm;
        previousRXVNorm = rXVNorm;

        // backtracking line search
        double s = 1d;
        DoubleMatrix1D X1 = null;
        DoubleMatrix1D V1 = null;
        DoubleMatrix1D gradX1 = null;
        DoubleMatrix1D rDualX1V1 = null;
        DoubleMatrix1D rPriX1V1 = null;
        double previousNormRX1V1 = Double.NaN;
        while (true) {
            // @TODO: can we use 9.7.1?
            X1 = X.copy().assign(stepX.copy().assign(Mult.mult(s)), Functions.plus);// X + s*stepX
            V1 = V.copy().assign(stepV.copy().assign(Mult.mult(s)), Functions.plus);// V + s*stepV
            if (isInDomainF0(X1)) {
                gradX1 = getGradF0(X1);
                rDualX1V1 = rDual(X1, V1, gradX1);
                rPriX1V1 = rPri(X1);
                double normRX1V1 = Math.sqrt(ALG.norm2(rDualX1V1) + ALG.norm2(rPriX1V1));
                if (normRX1V1 <= (1 - getAlpha() * s) * rXVNorm) {
                    break;
                }

                Log.d(MainActivity.JOPTIMIZER_LOGTAG, "normRX1V1: " + normRX1V1);
                if (!Double.isNaN(previousNormRX1V1)) {
                    if (previousNormRX1V1 <= normRX1V1) {
                        Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved in backtracking with norm");
                        break;
                    }
                }
                previousNormRX1V1 = normRX1V1;
            }

            s = getBeta() * s;
        }
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s);

        // update
        X = X1;
        V = V1;
    }

    long tStop = System.currentTimeMillis();
    Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart));
    response.setSolution(X.toArray());
    setOptimizationResponse(response);
    return response.getReturnCode();
}

From source file:it.geosolutions.android.map.loaders.FeatureCircleLoader.java

/**
 * Process a single <FeatureCircleQuery>
 * @param query/*from  w ww .j  av a2 s  . c om*/
 * @param data the result will be added to this array
 */
private boolean processQuery(FeatureCircleTaskQuery query, List<FeatureCircleQueryResult> data) {
    SpatialDataSourceHandler handler = query.getHandler();
    SpatialVectorTable table = query.getTable();
    String tableName = query.getTable().getName();
    // check visibility before adding the table
    // AdvancedStyle s = sm.getStyle(tableName);
    // if ( !StyleUtils.isVisible(s, zoomLevel) ) {
    // onProgressUpdate(0);
    // continue;
    // }

    double x = query.getX();
    double y = query.getY();
    double radius = query.getRadius();

    Integer start = query.getStart();
    Integer limit = query.getLimit();
    if (Log.isLoggable("FEATURE_Circle_TASK", Log.DEBUG)) { // Log check to avoid
                                                            // string creation
        Log.d("FEATURE_Circle_TASK", "starting query for table " + tableName);
    }
    // this is empty to skip geometries that returns errors
    ArrayList<Feature> features = new ArrayList<Feature>();
    try {
        features = handler.intersectionToCircle("4326", table, x, y, radius, start, limit);
    } catch (Exception e) {
        Log.e("FEATURE_Circle_TASK",
                "unable to retrive data for table'" + tableName + "\'.Error:" + e.getLocalizedMessage());
        // TODO now simply skip, do better work
    }
    // add features
    FeatureCircleQueryResult result = new FeatureCircleQueryResult();
    result.setLayerName(tableName);
    result.setFeatures(features);
    Log.v("FEATURE_Circle_TASK", features.size() + " items found for table " + tableName);
    features_loaded += features.size();
    // publishProgress(result);
    data.add(result);

    return true;

}