Android Open Source - Mamytas Logger From Project Back to project page Mamytas .
License The source code is released under:
GNU General Public License
If you think the Android project Mamytas 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 mn.aug.restfulandroid.util;
/ / w w w . j a v a 2 s . c o m
import java.util.Set;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
/**
* Utility class for logging
*
* @author jeremy
*
*/
public class Logger {
public static final int VERBOSE = Log.VERBOSE;
public static final int DEBUG = Log.DEBUG;
public static final int INFO = Log.INFO;
public static final int WARN = Log.WARN;
public static final int ERROR = Log.ERROR;
public static final int ASSERT = Log.ASSERT;
private static int mCurrentLevel = ASSERT;
private static String mAppLogTag = "" ;
public static void setAppTag(String appTag) {
mAppLogTag = appTag;
}
public static void setLevel(int level) {
mCurrentLevel = level;
}
public static int getLevel() {
return mCurrentLevel;
}
public static boolean isEnabled(int level) {
return level >= mCurrentLevel;
}
public static void debug(String tag, String message) {
Log.d(mAppLogTag, formatMessage(tag, message));
}
public static void debug(String tag, String message, Throwable throwable) {
Log.d(mAppLogTag, formatMessage(tag, message));
}
public static void debug(String tag, Intent intent) {
debug(tag, "Intent action=" + intent.getAction());
// log extras
Bundle extras = intent.getExtras();
if (extras != null) {
Set<String> keys = extras.keySet();
if (keys == null || (keys != null && keys.isEmpty())) {
debug(tag, " extras: none" );
} else {
debug(tag, " extras:" );
for (String key : keys) {
debug(tag, " " + key + "=" + extras.get(key));
}
}
}
}
public static void info(String tag, String message) {
Log.i(mAppLogTag, formatMessage(tag, message));
}
public static void error(String tag, String error) {
Log.e(mAppLogTag, formatMessage(tag, error));
}
public static void error(String tag, String error, Throwable throwable) {
Log.e(mAppLogTag, formatMessage(tag, error), throwable);
}
public static void warn(String tag, String message) {
Log.w(mAppLogTag, formatMessage(tag, message));
}
public static void warn(String tag, String message, Throwable throwable) {
Log.w(mAppLogTag, formatMessage(tag, message), throwable);
}
/**
* Formats a log message
*
* @param tag
* message prefix, typically the requesting class name
* @param message
* message to write
* @return formatted string of the log message
*/
private static String formatMessage(String tag, String message) {
StringBuilder builder = new StringBuilder();
if (tag.length() > 20) {
tag = tag.substring(0, 20);
}
tag = "[" + tag + "]" ;
String prefix = String.format("%-22s " , tag);
builder.append(prefix).append(message);
return builder.toString();
}
}
Java Source Code List mn.aug.restfulandroid.activity.AboutActivity.java mn.aug.restfulandroid.activity.LoginActivity.java mn.aug.restfulandroid.activity.ProjectEditor.java mn.aug.restfulandroid.activity.ProjectsActivity.java mn.aug.restfulandroid.activity.ProjectsArrayAdapter.java mn.aug.restfulandroid.activity.TaskActivity.java mn.aug.restfulandroid.activity.TaskEditor.java mn.aug.restfulandroid.activity.TasksActivity.java mn.aug.restfulandroid.activity.TasksArrayAdapter.java mn.aug.restfulandroid.activity.TimerServiceHelper.java mn.aug.restfulandroid.activity.TimerService.java mn.aug.restfulandroid.activity.TimersArrayAdapter.java mn.aug.restfulandroid.activity.base.RESTfulActivity.java mn.aug.restfulandroid.activity.base.RESTfulListActivity.java mn.aug.restfulandroid.activity.base.UndoBarController.java mn.aug.restfulandroid.provider.CommentsDBAccess.java mn.aug.restfulandroid.provider.ListsDBAccess.java mn.aug.restfulandroid.provider.OwnershipDBAccess.java mn.aug.restfulandroid.provider.ProviderDbHelper.java mn.aug.restfulandroid.provider.RemindersDBAccess.java mn.aug.restfulandroid.provider.TasksDBAccess.java mn.aug.restfulandroid.provider.UsersDBAccess.java mn.aug.restfulandroid.rest.AbstractRestMethod.java mn.aug.restfulandroid.rest.DeleteListRestMethod.java mn.aug.restfulandroid.rest.DeleteTaskRestMethod.java mn.aug.restfulandroid.rest.GetListsRestMethod.java mn.aug.restfulandroid.rest.GetTasksRestMethod.java mn.aug.restfulandroid.rest.GetTimersRestMethod.java mn.aug.restfulandroid.rest.LoginRestMethod.java mn.aug.restfulandroid.rest.PostListRestMethod.java mn.aug.restfulandroid.rest.PostTaskRestMethod.java mn.aug.restfulandroid.rest.PostTimerRestMethod.java mn.aug.restfulandroid.rest.PutListRestMethod.java mn.aug.restfulandroid.rest.PutTaskRestMethod.java mn.aug.restfulandroid.rest.PutTimerRestMethod.java mn.aug.restfulandroid.rest.Request.java mn.aug.restfulandroid.rest.Response.java mn.aug.restfulandroid.rest.RestClient.java mn.aug.restfulandroid.rest.RestMethodFactory.java mn.aug.restfulandroid.rest.RestMethodResult.java mn.aug.restfulandroid.rest.RestMethod.java mn.aug.restfulandroid.rest.ShareListRestMethod.java mn.aug.restfulandroid.rest.resource.Comment.java mn.aug.restfulandroid.rest.resource.Lists.java mn.aug.restfulandroid.rest.resource.Listw.java mn.aug.restfulandroid.rest.resource.Login.java mn.aug.restfulandroid.rest.resource.Reminder.java mn.aug.restfulandroid.rest.resource.Resource.java mn.aug.restfulandroid.rest.resource.TaskList.java mn.aug.restfulandroid.rest.resource.Task.java mn.aug.restfulandroid.rest.resource.Tasks.java mn.aug.restfulandroid.rest.resource.Timer.java mn.aug.restfulandroid.rest.resource.Timers.java mn.aug.restfulandroid.security.AuthorizationManager.java mn.aug.restfulandroid.security.RequestSigner.java mn.aug.restfulandroid.service.ListProcessor.java mn.aug.restfulandroid.service.ListsProcessor.java mn.aug.restfulandroid.service.LoginProcessor.java mn.aug.restfulandroid.service.ProcessorCallback.java mn.aug.restfulandroid.service.ShareProcessor.java mn.aug.restfulandroid.service.TaskProcessor.java mn.aug.restfulandroid.service.TasksProcessor.java mn.aug.restfulandroid.service.TimersProcessor.java mn.aug.restfulandroid.service.WunderlistServiceHelper.java mn.aug.restfulandroid.service.WunderlistService.java mn.aug.restfulandroid.util.DateHelper.java mn.aug.restfulandroid.util.DatePickerFragment.java mn.aug.restfulandroid.util.Logger.java mn.aug.restfulandroid.util.TimePickerFragment.java