Log Data Related Interfaces
Log instrumentationβ
By setting up log instrumentation, you can configure "log retrieval" tasks on the Newlens by Tingyun reporting platform to obtain log information from the instrumentation. You need to import the nbs.newlens.android.log package. Please refer to the deployment document for specifics.
- Related Interface
/**
* @param log Log content, maximum supported length is 4096.
* @param tag Log tags, maximum supported length is 128.
*/
NBSAppAgent.debugLog(String log, String tag);// Debug Log
NBSAppAgent.infoLog(String log, String tag);// Info Log
NBSAppAgent.warningLog(String log, String tag);// Warning Log
NBSAppAgent.errorLog(String log, String tag);// Error Log
- Code Example
NBSAppAgent.debugLog("login success", "login");
Custom log method encapsulation depth.β
The SDK log interface collects the class name, method name, and line number information of the class calling this interface. If the SDK log interface is encapsulated in a custom LogUtil class, you need to use the customLogInvokeStackTrace() method to set the depth of encapsulation calling. Then, the SDK can collect the class name, method name, and line number information of the class calling the LogUtil class method.
- Related Interface
/**
* @param index The depth of encapsulation calling needs to be set before initializing the SDK.
*/
NBSAppAgent.customLogInvokeStackTrace(int index);
- Code Example
public class LogUtil{
public static void debugLog(String log, String tag){
NBSAppAgent.debugLog(log, tag);
}
}
NBSAppAgent.customLogInvokeStackTrace(1);// Call before initializing the SDK.
public void onCreate() {
String tingYunDid = NBSAppAgent.getTingyunDeviceId();
if(!TextUtils.isEmpty(tingYunDid)){//If the deviceId does not exist, return null. It is advisable to check for null before usage.
...
}
}