Add getStateSummary method for diagnostics
Summary: Adds a more structured representation of state updates than a multiline string. Also changes the string form to omit [started] records. Reviewed By: danielbuechele Differential Revision: D9315503 fbshipit-source-id: 55b8f9572091fd42fe852c8d26a8f2a53f76c82a
This commit is contained in:
committed by
Facebook Github Bot
parent
e51b8c0742
commit
660da3f80e
@@ -14,6 +14,7 @@ import com.facebook.sonar.BuildConfig;
|
||||
import com.facebook.sonar.core.SonarClient;
|
||||
import com.facebook.sonar.core.SonarPlugin;
|
||||
import com.facebook.sonar.core.SonarStateUpdateListener;
|
||||
import com.facebook.sonar.core.StateSummary;
|
||||
|
||||
@DoNotStrip
|
||||
class SonarClientImpl implements SonarClient {
|
||||
@@ -65,4 +66,7 @@ class SonarClientImpl implements SonarClient {
|
||||
|
||||
@Override
|
||||
public native String getState();
|
||||
|
||||
@Override
|
||||
public native StateSummary getStateSummary();
|
||||
}
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface SonarClient {
|
||||
void unsubscribe();
|
||||
|
||||
String getState();
|
||||
|
||||
StateSummary getStateSummary();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.facebook.sonar.core;
|
||||
|
||||
public class StateElement {
|
||||
private final String mName;
|
||||
private final String mState;
|
||||
public StateElement(String name, String state) {
|
||||
mName = name;
|
||||
mState = state;
|
||||
}
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.facebook.sonar.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StateSummary {
|
||||
|
||||
public enum State {
|
||||
IN_PROGRESS, SUCCESS, FAILED, UNKNOWN;
|
||||
}
|
||||
|
||||
public static class StateElement {
|
||||
private final String mName;
|
||||
private final State mState;
|
||||
public StateElement(String name, State state) {
|
||||
mName = name;
|
||||
mState = state;
|
||||
}
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
public State getState() {
|
||||
return mState;
|
||||
}
|
||||
}
|
||||
|
||||
public final List<StateElement> mList = new ArrayList<>();
|
||||
|
||||
public void addEntry(String name, String state) {
|
||||
State s;
|
||||
try {
|
||||
s = State.valueOf(state);
|
||||
} catch (RuntimeException e) {
|
||||
s = State.UNKNOWN;
|
||||
}
|
||||
mList.add(new StateElement(name, s));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user