Skip to main content

Log Recall

Log Instrumentation​

By setting log instrumentation, you can configure "log recall" tasks on the Tingyun reporting platform to obtain instrumented log information. You need to introduce the nbs.newlens.android.log package, see the deployment documentation for details.

  • Related interface
/**
* @param log Log content, maximum length 4096
* @param tag Log tag, maximum length 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 successful", "login");

Custom Log Method Wrapping Depth​

The SDK log interface collects the class name, method name, and line number information of the class that calls the interface. If you wrap the SDK log interface in a custom LogUtil class, you need to set the wrapping call depth using the customLogInvokeStackTrace() method before SDK initialization. The SDK will then collect the class name, method name, and line number information of the class that calls the LogUtil method.

  • Related interface
/**
* @param index Wrapping call depth, must be called before SDK initialization
*/
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 SDK initialization