Android Open Source - encrypted-camera Crashlytics Tree






From Project

Back to project page encrypted-camera.

License

The source code is released under:

Apache License

If you think the Android project encrypted-camera 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 com.andrewreitz.encryptedcamera.logging;
/*from   w  ww  .  ja  va 2 s . c  om*/
import com.crashlytics.android.Crashlytics;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import timber.log.Timber;

public final class CrashlyticsTree extends Timber.HollowTree {
  private static final Pattern ANONYMOUS_CLASS = Pattern.compile("\\$\\d+$");

  private enum LogLevel {
    INFO,
    ERROR,
    WARNING
  }

  @Override public void i(String message, Object... args) {
    log(LogLevel.INFO, createTag(), formatString(message, args));
  }

  @Override public void i(Throwable t, String message, Object... args) {
    log(LogLevel.INFO, createTag(), formatString(message, args), t);
  }

  @Override public void w(String message, Object... args) {
    log(LogLevel.WARNING, createTag(), formatString(message, args));
  }

  @Override public void w(Throwable t, String message, Object... args) {
    log(LogLevel.WARNING, createTag(), formatString(message, args), t);
  }

  @Override public void e(String message, Object... args) {
    log(LogLevel.ERROR, createTag(), formatString(message, args));
  }

  @Override public void e(Throwable t, String message, Object... args) {
    log(LogLevel.ERROR, createTag(), formatString(message, args), t);
  }

  private void log(LogLevel logLevel, String tag, String message) {
    log(logLevel, tag, message, null);
  }

  private void log(LogLevel logLevel, String tag, String message, Throwable t) {
    Crashlytics.log(String.format("%s/%s: %s", logLevel, tag, message));
    Crashlytics.logException(t); // always log even if null, crashylitcs ignores them
  }

  /**
   * Create a tag from the calling class (4 up).
   * This is not exactly fast but then again this really shouldn't be called a lot
   */
  private static String createTag() {
    String tag = new Throwable().getStackTrace()[4].getClassName();
    Matcher m = ANONYMOUS_CLASS.matcher(tag);
    if (m.find()) {
      tag = m.replaceAll("");
    }
    return tag.substring(tag.lastIndexOf('.') + 1);
  }

  private static String formatString(String message, Object... args) {
    return args.length == 0 ? message : String.format(message, args);
  }
}




Java Source Code List

com.andrewreitz.encryptedcamera.EncryptedCameraApp.java
com.andrewreitz.encryptedcamera.bus.EncryptionEvent.java
com.andrewreitz.encryptedcamera.cache.ThumbnailCache.java
com.andrewreitz.encryptedcamera.di.annotation.CameraIntent.java
com.andrewreitz.encryptedcamera.di.annotation.EncryptedDirectory.java
com.andrewreitz.encryptedcamera.di.annotation.EncryptionErrorNotification.java
com.andrewreitz.encryptedcamera.di.annotation.EncryptionNotification.java
com.andrewreitz.encryptedcamera.di.annotation.ForActivity.java
com.andrewreitz.encryptedcamera.di.annotation.ForApplication.java
com.andrewreitz.encryptedcamera.di.annotation.InternalDecryptedDirectory.java
com.andrewreitz.encryptedcamera.di.annotation.MediaFormat.java
com.andrewreitz.encryptedcamera.di.annotation.UnlockNotification.java
com.andrewreitz.encryptedcamera.di.module.ActivityModule.java
com.andrewreitz.encryptedcamera.di.module.AndroidModule.java
com.andrewreitz.encryptedcamera.di.module.EncryptedCameraAppModule.java
com.andrewreitz.encryptedcamera.di.module.EncryptionModule.java
com.andrewreitz.encryptedcamera.di.module.FileSystemModule.java
com.andrewreitz.encryptedcamera.di.module.SharedPrefsModule.java
com.andrewreitz.encryptedcamera.encryption.EncryptionProviderImplTest.java
com.andrewreitz.encryptedcamera.encryption.EncryptionProviderImpl.java
com.andrewreitz.encryptedcamera.encryption.EncryptionProvider.java
com.andrewreitz.encryptedcamera.encryption.FullEncryptionTest.java
com.andrewreitz.encryptedcamera.encryption.KeyManagerImplTest.java
com.andrewreitz.encryptedcamera.encryption.KeyManagerImpl.java
com.andrewreitz.encryptedcamera.encryption.KeyManager.java
com.andrewreitz.encryptedcamera.exception.SDCardException.java
com.andrewreitz.encryptedcamera.externalstoreage.ExternalStorageManagerImpl.java
com.andrewreitz.encryptedcamera.externalstoreage.ExternalStorageManager.java
com.andrewreitz.encryptedcamera.filesystem.SecureDeleteImplTest.java
com.andrewreitz.encryptedcamera.filesystem.SecureDeleteImpl.java
com.andrewreitz.encryptedcamera.filesystem.SecureDelete.java
com.andrewreitz.encryptedcamera.image.ImageRotation.java
com.andrewreitz.encryptedcamera.logging.CrashlyticsTree.java
com.andrewreitz.encryptedcamera.service.EncryptionIntentService.java
com.andrewreitz.encryptedcamera.sharedpreference.AppPreferenceManagerTest.java
com.andrewreitz.encryptedcamera.sharedpreference.AppPreferenceManager.java
com.andrewreitz.encryptedcamera.sharedpreference.DefaultSharedPreferenceService.java
com.andrewreitz.encryptedcamera.sharedpreference.SharedPreferenceService.java
com.andrewreitz.encryptedcamera.ui.activity.AboutActivity.java
com.andrewreitz.encryptedcamera.ui.activity.BaseActivity.java
com.andrewreitz.encryptedcamera.ui.activity.CameraActivity.java
com.andrewreitz.encryptedcamera.ui.activity.GalleryActivity.java
com.andrewreitz.encryptedcamera.ui.activity.SettingsActivity.java
com.andrewreitz.encryptedcamera.ui.adapter.BindableAdapter.java
com.andrewreitz.encryptedcamera.ui.adapter.GalleryAdapter.java
com.andrewreitz.encryptedcamera.ui.controller.ActivityController.java
com.andrewreitz.encryptedcamera.ui.dialog.ErrorDialog.java
com.andrewreitz.encryptedcamera.ui.dialog.FirstRunDialog.java
com.andrewreitz.encryptedcamera.ui.dialog.PasswordDialog.java
com.andrewreitz.encryptedcamera.ui.dialog.SetPasswordDialog.java
com.andrewreitz.encryptedcamera.ui.fragment.AppPreferenceFragment.java
com.andrewreitz.encryptedcamera.ui.fragment.BaseFragment.java
com.andrewreitz.encryptedcamera.ui.fragment.GalleryFragment.java