diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-12-02 23:02:10 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-12-02 23:02:10 +0100 |
commit | a0dcdf5c762ff28edeea34c2cfe654c31889abc7 (patch) | |
tree | 9e92fc9f9f0bc44c2593c00e29290ad8f392747e /src/main/java/de/thedevstack/conversationsplus/utils | |
parent | 6bc277152a8e1bcf5347d3e1d60c93dfc904ca23 (diff) | |
parent | 9efc13983516c4c37540eb9544f8fa411ded81c7 (diff) |
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils')
3 files changed, 129 insertions, 5 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java index 77ec345d..6b080202 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java @@ -4,7 +4,7 @@ import android.graphics.Bitmap; import android.net.Uri; import android.util.Base64; import android.util.Base64OutputStream; -import android.util.Log; +import de.thedevstack.conversationsplus.utils.Logging; import java.io.ByteArrayOutputStream; import java.io.File; @@ -102,7 +102,7 @@ public final class AvatarUtil { if (sha1sum.equals(avatar.sha1sum)) { file.renameTo(new File(filename)); } else { - Log.d(Config.LOGTAG, "sha1sum mismatch for " + avatar.owner); + Logging.d(Config.LOGTAG, "sha1sum mismatch for " + avatar.owner); file.delete(); return false; } diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java index 07e41dcb..802c7ffb 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/ImageUtil.java @@ -7,7 +7,7 @@ import android.graphics.Matrix; import android.graphics.RectF; import android.media.ExifInterface; import android.net.Uri; -import android.util.Log; +import de.thedevstack.conversationsplus.utils.Logging; import android.util.LruCache; import java.io.File; @@ -67,7 +67,7 @@ public final class ImageUtil { * @see LruCache#LruCache(int) for details */ public static void initBitmapCache() { - Log.i("Conversations+ImageUtil", "Initializing BitmapCache"); + Logging.i("Conversations+ImageUtil", "Initializing BitmapCache"); final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cacheSize = maxMemory / 8; BITMAP_CACHE = new LruCache<String, Bitmap>(cacheSize) { @@ -178,7 +178,7 @@ public final class ImageUtil { return rotate(original, rotation); } } catch (IOException e) { - Log.w("filebackend", "Error while rotating image, returning original (" + e.getMessage() + ")"); + Logging.w("filebackend", "Error while rotating image, returning original (" + e.getMessage() + ")"); } return original; } diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java b/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java new file mode 100644 index 00000000..40ec66a0 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/utils/Logging.java @@ -0,0 +1,124 @@ +package de.thedevstack.conversationsplus.utils; + +import android.util.Log; + +/** + * Created by tzur on 20.11.2015. + */ +public class Logging { + protected static final String LOG_TAG_PREFIX = "thedevstack."; + /** + * Send a {@link Log#VERBOSE} log message. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int v(String tag, String msg) { + return Log.v(Logging.LOG_TAG_PREFIX + tag, msg); + } + + /** + * Send a {@link Log#VERBOSE} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int v(String tag, String msg, Throwable tr) { + return Log.v(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr)); + } + + /** + * Send a {@link Log#DEBUG} log message. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int d(String tag, String msg) { + return Log.d(Logging.LOG_TAG_PREFIX + tag, msg); + } + + /** + * Send a {@link Log#DEBUG} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int d(String tag, String msg, Throwable tr) { + return Log.d(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr)); + } + + /** + * Send an {@link Log#INFO} log message. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int i(String tag, String msg) { + return Log.i(Logging.LOG_TAG_PREFIX + tag, msg); + } + + /** + * Send a {@link Log#INFO} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int i(String tag, String msg, Throwable tr) { + return Log.i(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr)); + } + + /** + * Send a {@link Log#WARN} log message. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int w(String tag, String msg) { + return Log.w(Logging.LOG_TAG_PREFIX + tag, msg); + } + + /** + * Send a {@link Log#WARN} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int w(String tag, String msg, Throwable tr) { + return Log.w(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr)); + } + + /* + * Send a {@link #WARN} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param tr An exception to log + */ + public static int w(String tag, Throwable tr) { + return Log.w(Logging.LOG_TAG_PREFIX + tag, Log.getStackTraceString(tr)); + } + + /** + * Send an {@link Log#ERROR} log message. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + */ + public static int e(String tag, String msg) { + return Log.e(Logging.LOG_TAG_PREFIX + tag, msg); + } + + /** + * Send a {@link Log#ERROR} log message and log the exception. + * @param tag Used to identify the source of a log message. It usually identifies + * the class or activity where the log call occurs. + * @param msg The message you would like logged. + * @param tr An exception to log + */ + public static int e(String tag, String msg, Throwable tr) { + return Log.e(Logging.LOG_TAG_PREFIX + tag, msg + '\n' + Log.getStackTraceString(tr)); + } +} |