Android Open Source - GuiLib Debug






From Project

Back to project page GuiLib.

License

The source code is released under:

Apache License

If you think the Android project GuiLib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2010 Gandulf Kohlweiss/*  ww  w  . j  a  va 2  s . c o  m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gandulf.guilib.util;

import android.util.Log;

import com.gandulf.guilib.BuildConfig;

/**
 * Functions and helpers to aid debugging. DebugMode can be toggled .
 */
public class Debug {

  private static String tag = "GuiLib";

  protected static boolean debugMode = BuildConfig.DEBUG;

  public static String getDebugTag() {
    return tag;
  }

  /**
   * Sets the tag to be used in LogCat debug messages If unset, it will default to "GuiLib"
   * 
   * @param tag
   *            any valid String for LogCat tags
   */
  public static void setDebugTag(String tag) {
    Debug.tag = tag;
  }

  /**
   * Prints a warning to LogCat with information
   * 
   * @param source
   *            The source of the warning, such as function name
   * @param message
   *            The message to be passed on
   */
  public static void warning(String source, String message) {
    if (!debugMode)
      return;
    Log.w(tag, source + " - " + message);
    Exception e = new Exception(source + " - " + message);
    e.printStackTrace();
  }

  /**
   * Prints a warning to LogCat with information
   * 
   * @param message
   *            The message to be passed on
   */
  public static void warning(String message, Throwable throwable) {
    if (debugMode)
      Log.w(tag, message, throwable);
  }

  /**
   * Prints a warning to LogCat with information
   * 
   * @param message
   *            The message to be passed on
   */
  public static void warning(String message) {
    if (!debugMode)
      return;
    Log.w(tag, message);
  }

  /**
   * Prints to the verbose stream of LogCat with information
   * 
   * @param message
   *            The message to be passed on
   */
  public static void print(String message) {
    if (!debugMode)
      return;
    Log.v(tag, message);
  }

  /**
   * Prints to the error stream of LogCat with information
   * 
   * @param message
   *            The message to be passed on
   */
  public static void error(String message) {
    Log.e(tag, message);
    Exception e = new Exception(message);
    e.printStackTrace();
  }

  public static void error(String message, Throwable e) {
    Log.e(tag, message);
    e.printStackTrace();
  }

  /**
   * Prints to the error stream of LogCat with information from the engine
   * 
   * @param message
   *            The message to be passed on
   */
  public static void warn(Throwable t) {
    Log.w(tag, t.getMessage(), t);
  }

  /**
   * Prints to the error stream of LogCat with information
   * 
   * @param message
   *            The message to be passed on
   */
  public static void error(Throwable t) {
    Log.e(tag, t.getMessage(), t);
  }

  /**
   * Prints to the verbose stream of LogCat, with information
   * 
   * 
   * @param method
   * @param message
   */
  public static void verbose(String method, String message) {
    if (!debugMode)
      return;
    Log.v(tag, method + " - " + message);
  }

  public static void heap() {
    Log.w("MEMORY",
        "HeapSize: " + (android.os.Debug.getNativeHeapSize() / (1024)) + "kb Used: "
            + (android.os.Debug.getNativeHeapAllocatedSize() / (1024)) + "kb Free: "
            + (android.os.Debug.getNativeHeapFreeSize() / (1024)) + "kb");
  }

  /**
   * Prints to the verbose stream of LogCat, with information
   * 
   * 
   * @param message
   */
  public static void verbose(String message) {
    if (!debugMode)
      return;
    Log.v(tag, message);
  }

}




Java Source Code List

au.com.bytecode.opencsv.CSVReader.java
com.ecloud.pulltozoomview.PullToZoomScrollView.java
com.gandulf.guilib.data.OpenArrayAdapter.java
com.gandulf.guilib.data.OpenFilter.java
com.gandulf.guilib.download.AbstractDownloader.java
com.gandulf.guilib.download.DownloadBroadcastReceiver.java
com.gandulf.guilib.download.DownloaderGinger.java
com.gandulf.guilib.download.DownloaderWrapper.java
com.gandulf.guilib.download.Downloader.java
com.gandulf.guilib.download.MediaScannerWrapper.java
com.gandulf.guilib.download.UnzipIntentService.java
com.gandulf.guilib.listener.CheckableListenable.java
com.gandulf.guilib.listener.OnCheckedChangeListener.java
com.gandulf.guilib.util.ColorUtil.java
com.gandulf.guilib.util.Debug.java
com.gandulf.guilib.util.DefaultTextWatcher.java
com.gandulf.guilib.util.DirectoryFileFilter.java
com.gandulf.guilib.util.FileFileFilter.java
com.gandulf.guilib.util.ListViewCompat.java
com.gandulf.guilib.util.MathUtil.java
com.gandulf.guilib.util.ResUtil.java
com.gandulf.guilib.view.ColorPickerDialog.java
com.gandulf.guilib.view.DynamicListViewEx.java
com.gandulf.guilib.view.HackeyDrawerLayout.java
com.gandulf.guilib.view.SeekBarEx.java
com.gandulf.guilib.view.VersionInfoDialog.java
com.gandulf.guilib.view.ViewScroller.java
com.gandulf.guilib.view.adapter.MultiFragmentPagerAdapter.java
com.getbase.floatingactionbutton.AddFloatingActionButton.java
com.getbase.floatingactionbutton.FloatingActionButton.java
com.getbase.floatingactionbutton.FloatingActionsMenu.java
com.github.amlcurran.showcaseview.AnimationFactory.java
com.github.amlcurran.showcaseview.AnimatorAnimationFactory.java
com.github.amlcurran.showcaseview.ApiUtils.java
com.github.amlcurran.showcaseview.Calculator.java
com.github.amlcurran.showcaseview.NewShowcaseDrawer.java
com.github.amlcurran.showcaseview.OnShowcaseEventListener.java
com.github.amlcurran.showcaseview.ShotStateStore.java
com.github.amlcurran.showcaseview.ShowcaseAreaCalculator.java
com.github.amlcurran.showcaseview.ShowcaseDrawer.java
com.github.amlcurran.showcaseview.ShowcaseView.java
com.github.amlcurran.showcaseview.StandardShowcaseDrawer.java
com.github.amlcurran.showcaseview.TextDrawer.java
com.github.amlcurran.showcaseview.targets.ActionBarReflector.java
com.github.amlcurran.showcaseview.targets.ActionBarViewWrapper.java
com.github.amlcurran.showcaseview.targets.ActionItemTarget.java
com.github.amlcurran.showcaseview.targets.ActionViewTarget.java
com.github.amlcurran.showcaseview.targets.AppCompatReflector.java
com.github.amlcurran.showcaseview.targets.PointTarget.java
com.github.amlcurran.showcaseview.targets.ReflectorFactory.java
com.github.amlcurran.showcaseview.targets.Reflector.java
com.github.amlcurran.showcaseview.targets.SherlockReflector.java
com.github.amlcurran.showcaseview.targets.Target.java
com.github.amlcurran.showcaseview.targets.ViewTarget.java
com.sothree.slidinguppanel.SlidingUpPanelLayout.java
com.sothree.slidinguppanel.ViewDragHelper.java
com.thebnich.floatinghintedittext.FloatingHintEditText.java
com.thebnich.floatinghintedittext.FloatingHintTextView.java
com.wefika.flowlayout.FlowLayout.java
de.hdodenhof.circleimageview.CircleImageView.java
uk.co.senab.photoview.Compat.java
uk.co.senab.photoview.PhotoViewAttacher.java
uk.co.senab.photoview.PhotoView.java
uk.co.senab.photoview.SDK16.java
uk.co.senab.photoview.ScrollerProxy.java
uk.co.senab.photoview.VersionedGestureDetector.java
uk.me.lewisdeane.ldialogs.BaseDialog.java
uk.me.lewisdeane.ldialogs.CustomDialog.java
uk.me.lewisdeane.ldialogs.CustomListAdapter.java