If you think the Android project muzei 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 2014 Google Inc./*fromwww.java2s.com*/
*
* 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.google.android.apps.muzei.util;
import android.util.Log;
import net.nurik.roman.muzei.BuildConfig;
/**
* Helper methods that make logging more consistent throughout the app.
*/publicclass LogUtil {
privatestaticfinal String TAG = makeLogTag(LogUtil.class);
privatestaticfinal String LOG_PREFIX = "muzei_";
privatestaticfinalint LOG_PREFIX_LENGTH = LOG_PREFIX.length();
privatestaticfinalint MAX_LOG_TAG_LENGTH = 23;
private LogUtil() {
}
publicstatic String makeLogTag(String str) {
if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH - 1);
}
return LOG_PREFIX + str;
}
/**
* WARNING: Don't use this when obfuscating class names with Proguard!
*/publicstatic String makeLogTag(Class cls) {
return makeLogTag(cls.getSimpleName());
}
publicstaticvoid LOGD(final String tag, String message) {
//noinspection PointlessBooleanExpression,ConstantConditions
if (BuildConfig.DEBUG || Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, message);
}
}
publicstaticvoid LOGD(final String tag, String message, Throwable cause) {
//noinspection PointlessBooleanExpression,ConstantConditions
if (BuildConfig.DEBUG || Log.isLoggable(tag, Log.DEBUG)) {
Log.d(tag, message, cause);
}
}
publicstaticvoid LOGV(final String tag, String message) {
//noinspection PointlessBooleanExpression,ConstantConditions
if (BuildConfig.DEBUG && Log.isLoggable(tag, Log.VERBOSE)) {
Log.v(tag, message);
}
}
publicstaticvoid LOGV(final String tag, String message, Throwable cause) {
//noinspection PointlessBooleanExpression,ConstantConditions
if (BuildConfig.DEBUG && Log.isLoggable(tag, Log.VERBOSE)) {
Log.v(tag, message, cause);
}
}
publicstaticvoid LOGI(final String tag, String message) {
Log.i(tag, message);
}
publicstaticvoid LOGI(final String tag, String message, Throwable cause) {
Log.i(tag, message, cause);
}
publicstaticvoid LOGW(final String tag, String message) {
if (BuildConfig.DEBUG) {
Log.w(tag, message, new Throwable()); // create a stacktrace
} else {
Log.w(tag, message);
}
}
publicstaticvoid LOGW(final String tag, String message, Throwable cause) {
Log.w(tag, message, cause);
}
publicstaticvoid LOGE(final String tag, String message) {
if (BuildConfig.DEBUG) {
Log.e(tag, message, new Throwable()); // create a stacktrace
} else {
Log.e(tag, message);
}
}
publicstaticvoid LOGE(final String tag, String message, Throwable cause) {
Log.e(tag, message, cause);
}
}