Skip to content

Commit

Permalink
Change the 'execute' method call to print.
Browse files Browse the repository at this point in the history
  • Loading branch information
Muyangmin committed Jun 13, 2017
1 parent a348efd commit 28fe760
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/org/mym/prettylog/MainActivity.java
Expand Up @@ -263,7 +263,7 @@ void printLog() {
String content = mEdtLogContent.getText().toString().trim();

if (!TextUtils.isEmpty(content)) {
PLog.category(category).msg(content).execute();
PLog.category(category).msg(content).print();
} else {
PLog.empty();
}
Expand Down Expand Up @@ -329,7 +329,7 @@ void logBasic() {
new Thread("BackgroundThread") {
@Override
public void run() {
PLog.level(Log.INFO).msg("This is a log in another thread.").execute();
PLog.level(Log.INFO).msg("This is a log in another thread.").print();
}
}.start();
}
Expand Down Expand Up @@ -370,11 +370,11 @@ void logThrowable() {
PLog.throwable(e);

//force using error level
PLog.level(Log.ERROR).throwable(e).execute();
PLog.level(Log.ERROR).throwable(e).print();

//Using crash category
PLog.level(Log.WARN).category(CrashPrinter.CAT_CRASH)
.params(e).execute();
.params(e).print();
}

void logJSON() {
Expand Down Expand Up @@ -448,7 +448,7 @@ void logTiming() {
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void logCrash() {
PLog.level(Log.ERROR).category(CrashPrinter.CAT_CRASH).params(new NullPointerException())
.execute();
.print();
String path = CrashPrinter.getInstance(this).getLogFilePath();
toastMsg(R.string.msg_crash_saved, path);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mym/prettylog/util/CrashHandler.java
Expand Up @@ -49,7 +49,7 @@ public void uncaughtException(Thread thread, Throwable throwable) {
//TODO consider remove this on release version
throwable.printStackTrace();
CrashPrinter.setExtraInfo(generateExtraInfo(thread));
PLog.level(Log.ERROR).category(CrashPrinter.CAT_CRASH).params(throwable).execute();
PLog.level(Log.ERROR).category(CrashPrinter.CAT_CRASH).params(throwable).print();
if (mDefaultHandler != null) {
mDefaultHandler.uncaughtException(thread, throwable);
}
Expand Down
Expand Up @@ -87,6 +87,6 @@ public void dumpToLog() {
}

private void callLogger(String tag, String msg){
PLog.level(Log.DEBUG).tag(tag).msg(msg).stackOffset(2).execute();
PLog.level(Log.DEBUG).tag(tag).msg(msg).stackOffset(2).print();
}
}
22 changes: 11 additions & 11 deletions plog/src/main/java/org/mym/plog/PLog.java
Expand Up @@ -76,23 +76,23 @@ public static LogRequest tag(@NonNull String tag){

public static void v(String msg, Object... params) {
//TODO implement a pool of logRequest
new LogRequest().level(Log.VERBOSE).msg(msg).params(params).stackOffset(1).execute();
new LogRequest().level(Log.VERBOSE).msg(msg).params(params).stackOffset(1).print();
}

public static void d(String msg, Object... params) {
new LogRequest().level(Log.DEBUG).msg(msg).params(params).stackOffset(1).execute();
new LogRequest().level(Log.DEBUG).msg(msg).params(params).stackOffset(1).print();
}

public static void i(String msg, Object... params) {
new LogRequest().level(Log.INFO).msg(msg).params(params).stackOffset(1).execute();
new LogRequest().level(Log.INFO).msg(msg).params(params).stackOffset(1).print();
}

public static void w(String msg, Object... params) {
new LogRequest().level(Log.WARN).msg(msg).params(params).stackOffset(1).execute();
new LogRequest().level(Log.WARN).msg(msg).params(params).stackOffset(1).print();
}

public static void e(String msg, Object... params) {
new LogRequest().level(Log.ERROR).msg(msg).params(params).stackOffset(1).execute();
new LogRequest().level(Log.ERROR).msg(msg).params(params).stackOffset(1).print();
}

/**
Expand All @@ -102,15 +102,15 @@ public static void e(String msg, Object... params) {
public static void empty() {
new LogRequest().level(getCurrentConfig().getEmptyMsgLevel())
.msg(getCurrentConfig().getEmptyMsg())
.stackOffset(1).execute();
.stackOffset(1).print();
}

/**
* A helper method to print a PLOG call stack trace here.
* @since 2.0.0-beta4
*/
public static void printStackTraceHere() {
new LogRequest().level(Log.INFO).printTraceOnly().execute();
new LogRequest().level(Log.INFO).printTraceOnly().print();
}

/**
Expand All @@ -120,29 +120,29 @@ public static void printStackTraceHere() {
* @param params objects to print.
*/
public static void objects(Object... params) {
new LogRequest().level(Log.DEBUG).params(params).stackOffset(1).execute();
new LogRequest().level(Log.DEBUG).params(params).stackOffset(1).print();
}

/**
* Print json string.
* @since 2.0.0
*/
public static void json(JSONObject jsonObject) {
new LogRequest().level(Log.DEBUG).params(jsonObject).stackOffset(1).execute();
new LogRequest().level(Log.DEBUG).params(jsonObject).stackOffset(1).print();
}

/**
* Print exceptions in WARN level.
*/
public static void throwable(Throwable throwable) {
new LogRequest().level(Log.WARN).params(throwable).stackOffset(1).execute();
new LogRequest().level(Log.WARN).params(throwable).stackOffset(1).print();
}

/**
* What a Terrible Failure: Report an exception that should never happen.
*/
public static void wtf(Throwable throwable) {
new LogRequest().level(Log.ERROR).params(throwable).stackOffset(1).execute();
new LogRequest().level(Log.ERROR).params(throwable).stackOffset(1).print();
}

private static void checkInitOrUseDefaultConfig() {
Expand Down

0 comments on commit 28fe760

Please sign in to comment.