Custom log output implementation
By implementing the LogProxy API, you can control the internal logging of the mini program SDK.
Sample code:
@ProxyService(proxy = LogProxy.class)
public class LogProxyImpl extends LogProxy {
@Override
public void log(int logLevel, String tag, String msg, Throwable t) {
switch (logLevel) {
case Log.DEBUG:
if (t == null) {
android.util.Log.d(tag, msg);
} else {
android.util.Log.d(tag, msg, t);
}
break;
case Log.INFO:
if (t == null) {
android.util.Log.i(tag, msg);
} else {
android.util.Log.i(tag, msg, t);
}
break;
case Log.WARN:
if (t == null) {
android.util.Log.w(tag, msg);
} else {
android.util.Log.w(tag, msg, t);
}
break;
case Log.ERROR:
if (t == null) {
android.util.Log.e(tag, msg);
} else {
android.util.Log.e(tag, msg, t);
}
break;
default:
if (t == null) {
android.util.Log.v(tag, msg);
} else {
android.util.Log.v(tag, msg, t);
}
break;
}
}
@Override
public boolean isColorLevel() {
return true;
}
}
Custom Event Reporting
The host APP can override the internal reporting logic of TCMPP SDK by implementing the reportMiniAppEvent method of MiniAppProxy to customize the mini program event reporting.
Note:
Includes mini program operation events and the data reported by calling wx.reportEvent inside the mini program.
API is as follows:
public abstract boolean reportMiniAppEvent(int eId, String eventName, JSONObject props, MiniApp app);
The built-in event IDs are described below:
public static final int EID_None = 0;
.
public static final int EID_OPEN_MINIAPP = 1;
public static final int EID_OPEN_MINIAPP = 1.
public static final int EID_UPDATE_MINIAPP = 2;
public static final int EID_DOWNLOAD_MINIAPP = 3;
public static final int EID_MINIAPP_PAGE_VIEW = 4;
public static final int EID_MINIAPP_PAGE_VIEW = 4.
public static final int EID_EXIT_MINIAPP = 5;
public static final int EID_MINIAPP_ACTION = 6;
Customised Log Reporting
Real Time Log Reporting
The host APP can customize the mini program real-time event log reporting logic by implementing the reportRealTimeLog method of MiniAppProxy.
Note:
Include the log data written by the mini program internal call wx.getRealtimeLogManager.
API is as follows:
public abstract boolean reportRealTimeLog(String page, String jsLibVersion, MiniApp app, String[] filterMsgs,
ArrayList<RealTimeLogItem> logs);
Internal log reporting for mini programs
The host APP can customise the complaint feedback page of the mini program to collect the log upload logic by implementing the uploadUserLog method of MiniAppProxy.
Note:
This includes log data written by the mini program's internal call to wx.getLogManager, and the user can upload printed logs by using the button component's open-type="feedback".
public abstract boolean uploadUserLog(String appId, String logPath);
Was this page helpful?