Android Open Source - EBrowser Dbg






From Project

Back to project page EBrowser.

License

The source code is released under:

GNU General Public License

If you think the Android project EBrowser 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

package org.emergent.android.weave.client;
/*from   w  w w .  j av a 2 s  .c om*/
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

/**
 * @author Patrick Woodworth
 */
class Dbg {

  private static final Level LEVEL_ANDROID_VERBOSE = Level.FINE; // should never ship using this
  private static final Level LEVEL_ANDROID_DEBUG = Level.CONFIG; // stripped at runtime (except on emulator?)
  @SuppressWarnings("unused")
private static final Level LEVEL_ANDROID_INFO = Level.INFO;
  private static final Level LEVEL_ANDROID_WARN = Level.WARNING;
  @SuppressWarnings("unused")
private static final Level LEVEL_ANDROID_ERROR = Level.SEVERE;

  @SuppressWarnings("unused")
private static final Level LEVEL_V = LEVEL_ANDROID_VERBOSE;
//  private static final Level LEVEL_D = LEVEL_ANDROID_INFO;
  private static final Level LEVEL_D = LEVEL_ANDROID_DEBUG;
  private static final Level LEVEL_W = LEVEL_ANDROID_WARN;

  private static final Logger sm_logger = Logger.getLogger(WeaveConstants.LOGGER_NAME_FULL);

  private Dbg() {
    // no instantiation
  }

  public static void v(String fmt, Object... args) {
//    logf(LEVEL_V, fmt, args);
  }

  public static void v(Throwable e, String fmt, Object... args) {
//    logf(LEVEL_V, e, fmt, args);
  }

  public static void v(Throwable e) {
//    log(LEVEL_V, e);
  }

  public static void d(String fmt, Object... args) {
    logf(LEVEL_D, fmt, args);
  }

  public static void d(Throwable e, String fmt, Object... args) {
    logf(LEVEL_D, e, fmt, args);
  }

  public static void d(Throwable e) {
    log(LEVEL_D, e);
  }

  public static void w(String fmt, Object... args) {
    logf(LEVEL_W, fmt, args);
  }

  public static void w(Throwable e, String fmt, Object... args) {
    logf(LEVEL_W, e, fmt, args);
  }

  public static void w(Throwable e) {
    log(LEVEL_W, e);
  }

  private static void log(Level level, Throwable e) {
    if (!sm_logger.isLoggable(level))
      return;
    LogRecord lr = new DebugLogRecord(level, "Something was thrown!");
    lr.setThrown(e);
    lr.setLoggerName(sm_logger.getName());
    sm_logger.log(lr);
  }

  private static void logf(Level level, Throwable e, String msg, Object... params) {
    if (!sm_logger.isLoggable(level))
      return;
    LogRecord lr = new DebugLogRecord(level, String.format(msg, params));
    lr.setThrown(e);
    lr.setLoggerName(sm_logger.getName());
    sm_logger.log(lr);
  }

  private static void logf(Level level, String msg, Object... params) {
    if (!sm_logger.isLoggable(level))
      return;
    LogRecord lr = new DebugLogRecord(level, String.format(msg, params));
    lr.setLoggerName(sm_logger.getName());
    sm_logger.log(lr);
  }

  @SuppressWarnings("serial")
public static class DebugLogRecord extends LogRecord {

    /**
     * @serial Class that issued logging call
     */
    private String sourceClassName;

    /**
     * @serial Method that issued logging call
     */
    private String sourceMethodName;

    private transient boolean needToInferCaller = true;

    DebugLogRecord(Level level, String msg) {
      super(level, msg);
    }

    /**
     * {@inheritDoc}
     */
    public String getSourceClassName() {
      if (sourceClassName == null) {
        inferCaller();
      }
      return sourceClassName;
    }

    /**
     * {@inheritDoc}
     */
    public void setSourceClassName(String sourceClassName) {
      this.sourceClassName = sourceClassName;
      needToInferCaller = false;
    }

    /**
     * {@inheritDoc}
     */
    public String getSourceMethodName() {
      if (needToInferCaller) {
        inferCaller();
      }
      return sourceMethodName;
    }

    /**
     * {@inheritDoc}
     */
    public void setSourceMethodName(String sourceMethodName) {
      this.sourceMethodName = sourceMethodName;
      needToInferCaller = false;
    }

    private void inferCaller() {
      // Get the stack trace.
      StackTraceElement stack[] = (new Throwable()).getStackTrace();
      // First, search back to a method in the Logger class.
      int ix = 0;
      while (ix < stack.length) {
        StackTraceElement frame = stack[ix];
        String cname = frame.getClassName();
        if (cname.equals(Dbg.class.getName())) {
          break;
        }
        ix++;
      }
      // Now search for the first frame before the "Logger" class.
      while (ix < stack.length) {
        StackTraceElement frame = stack[ix];
        String cname = frame.getClassName();
        if (!cname.equals(Dbg.class.getName())) {
          // We've found the relevant frame.
          setSourceClassName(cname);
          setSourceMethodName(frame.getMethodName());
          return;
        }
        ix++;
      }
      // We haven't found a suitable frame, so just punt.  This is
      // OK as we are only committed to making a "best effort" here.
    }
  }
}




Java Source Code List

org.emergent.android.weave.client.Base32.java
org.emergent.android.weave.client.Base64Encoder.java
org.emergent.android.weave.client.Base64.java
org.emergent.android.weave.client.BulkKeyCouplet.java
org.emergent.android.weave.client.Dbg.java
org.emergent.android.weave.client.HexEncoder.java
org.emergent.android.weave.client.Hex.java
org.emergent.android.weave.client.QueryParams.java
org.emergent.android.weave.client.QueryResult.java
org.emergent.android.weave.client.UserWeave.java
org.emergent.android.weave.client.WeaveAccountInfo.java
org.emergent.android.weave.client.WeaveBasicObject.java
org.emergent.android.weave.client.WeaveConstants.java
org.emergent.android.weave.client.WeaveCryptoUtil.java
org.emergent.android.weave.client.WeaveException.java
org.emergent.android.weave.client.WeaveFactory.java
org.emergent.android.weave.client.WeaveHeader.java
org.emergent.android.weave.client.WeaveResponse.java
org.emergent.android.weave.client.WeaveSSLSocketFactory.java
org.emergent.android.weave.client.WeaveTransport.java
org.emergent.android.weave.client.WeaveUtil.java
org.greendroid.QuickActionGrid.java
org.greendroid.QuickActionWidget.java
org.greendroid.QuickAction.java
org.zirco.controllers.Controller.java
org.zirco.events.EventConstants.java
org.zirco.events.EventController.java
org.zirco.events.IDownloadEventsListener.java
org.zirco.model.DbAdapter.java
org.zirco.model.UrlSuggestionItemComparator.java
org.zirco.model.adapters.BookmarksCursorAdapter.java
org.zirco.model.adapters.DownloadListAdapter.java
org.zirco.model.adapters.HistoryExpandableListAdapter.java
org.zirco.model.adapters.UrlSuggestionCursorAdapter.java
org.zirco.model.adapters.WeaveBookmarksCursorAdapter.java
org.zirco.model.items.BookmarkItem.java
org.zirco.model.items.DownloadItem.java
org.zirco.model.items.HistoryItem.java
org.zirco.model.items.UrlSuggestionItem.java
org.zirco.model.items.WeaveBookmarkItem.java
org.zirco.providers.BookmarksProviderWrapper.java
org.zirco.providers.WeaveColumns.java
org.zirco.providers.WeaveContentProvider.java
org.zirco.providers.ZircoBookmarksContentProvider.java
org.zirco.sync.ISyncListener.java
org.zirco.sync.WeaveSyncTask.java
org.zirco.ui.activities.AboutActivity.java
org.zirco.ui.activities.AdBlockerWhiteListActivity.java
org.zirco.ui.activities.BookmarksHistoryActivity.java
org.zirco.ui.activities.BookmarksListActivity.java
org.zirco.ui.activities.ChangelogActivity.java
org.zirco.ui.activities.DownloadsListActivity.java
org.zirco.ui.activities.EditBookmarkActivity.java
org.zirco.ui.activities.HistoryListActivity.java
org.zirco.ui.activities.IToolbarsContainer.java
org.zirco.ui.activities.MainActivity.java
org.zirco.ui.activities.MobileViewListActivity.java
org.zirco.ui.activities.WeaveBookmarksListActivity.java
org.zirco.ui.activities.preferences.BaseSpinnerCustomPreferenceActivity.java
org.zirco.ui.activities.preferences.HomepagePreferenceActivity.java
org.zirco.ui.activities.preferences.PreferencesActivity.java
org.zirco.ui.activities.preferences.SearchUrlPreferenceActivity.java
org.zirco.ui.activities.preferences.UserAgentPreferenceActivity.java
org.zirco.ui.activities.preferences.WeavePreferencesActivity.java
org.zirco.ui.activities.preferences.WeaveServerPreferenceActivity.java
org.zirco.ui.components.CustomWebViewClient.java
org.zirco.ui.components.CustomWebView.java
org.zirco.ui.runnables.DownloadRunnable.java
org.zirco.ui.runnables.FaviconUpdaterRunnable.java
org.zirco.ui.runnables.HideToolbarsRunnable.java
org.zirco.ui.runnables.HistoryUpdater.java
org.zirco.ui.runnables.XmlHistoryBookmarksExporter.java
org.zirco.ui.runnables.XmlHistoryBookmarksImporter.java
org.zirco.utils.AnimationManager.java
org.zirco.utils.ApplicationUtils.java
org.zirco.utils.Constants.java
org.zirco.utils.DateUtils.java
org.zirco.utils.IOUtils.java
org.zirco.utils.ProxyChangeReceiver.java
org.zirco.utils.ProxySettings.java
org.zirco.utils.UrlUtils.java