tencent cloud

Tencent Cloud Observability Platform

API Description

Download
Focus Mode
Font Size
Last updated: 2026-05-25 18:01:58
This article describes the feature APIs of the Terminal Performance Monitoring Pro (RUM Pro) log SDK to facilitate flexible and in-depth integration.

Diagnose

Diagnose is the diagnostic module of the application. It is used to manage the configuration, collection, and reporting of diagnostic data. Below are the detailed API descriptions.

TDDiag

The TDDiag API provides features, such as initialization configuration, user ID configuration, receiving push requests, proactive log reporting, and refreshing configuration, for managing and reporting diagnostic logs of the application.
object TDDiag {

/**
* Initialization.
*
* @param context
* @param config
*/
fun initialize(context: Context, config: TDDiagConfig)

/**
* Initialization.
*
* @param context
* @param config
* @param host When multiple processes are initialized, this should be set to true for only one process. By default, this process is the main process and is used to pull configurations and upload logs.
*/
fun initialize(context: Context, config: TDDiagConfig, host: Boolean)

/**
* Configures userId.
*/
fun setUserId(id: String)

/**
* This is used to receive push requests.
*/
fun onPush(data: String)

/**
* Proactively reports logs.
*
* @param label Tag. This is required and cannot exceed 64 bytes.
* @param fileList List of file paths.
* @param summary Summary. This cannot exceed 256 bytes and can be searched.
* @param extraInfo Additional information.
* @param listener UI callback.
* @param saveSync Indicates whether to only synchronously save the task and upload data on the next startup.
* @see upload
*/
@Deprecated("Use TDDiag.upload(param) instead")
@JvmStatic
fun uploadFiles(
label: String,
fileList: List<File>,
summary: String? = null,
extraInfo: String? = null,
listener: UploadListener? = null,
saveSync: Boolean = false
)

/**
* Proactively reports logs.
*
* @param label Tag. This is required and cannot exceed 64 bytes.
* @param pathList List of file paths.
* @param summary Summary. This cannot exceed 256 bytes and can be searched.
* @param extraInfo Additional information.
* @param listener UI callback.
* @param saveSync Indicates whether to only synchronously save the task and upload data on the next startup.
* @see upload
*/
@Deprecated("Use TDDiag.upload(param) instead")
@JvmStatic
fun uploadPaths(
label: String,
pathList: List<String>,
summary: String? = null,
extraInfo: String? = null,
listener: UploadListener? = null,
saveSync: Boolean = false
)

/**
* Proactively reports logs.
*
* @param label Tag. This is required and cannot exceed 64 bytes.
* @param startTimestamp Starting timestamp (unit: seconds). This value is included.
* @param endTimestamp Ending timestamp (unit: seconds). This value is not included.
* @param extraPathList List of file paths.
* @param summary Summary. This cannot exceed 256 bytes and can be searched.
* @param extraInfo Additional information.
* @param listener UI callback.
* @param saveSync Indicates whether to only synchronously save the task and upload data on the next startup.
* @param sizeLimit File size limit (before compression). This is effective when the value is less than the [limits](README.md). No limit is applied by default.
* @see upload
*/
@Deprecated("Use TDDiag.upload(param) instead")
@JvmStatic
fun uploadLogs(
label: String,
startTimestamp: Long,
endTimestamp: Long,
extraPathList: List<String>? = null,
summary: String? = null,
extraInfo: String? = null,
listener: UploadListener? = null,
saveSync: Boolean = false,
sizeLimit: Long = Long.MAX_VALUE
)

/**
* Proactively reports logs.
*/
@JvmStatic
fun upload(param: UploadParam)

/**
* Proactively refreshes the configuration.
*
* @param force Indicates whether to force refresh without checking the pull interval.
*/
fun syncConfig(force: Boolean = false): Boolean
}

TDDiagConfig.Builder

The TDDiagConfig.Builder API is used to configure the parameters required by TDDiag (such as appId, appKey, log adapter, and traffic quota) through chained methods, ultimately building a TDDiagConfig instance.
class TDDiagConfig.Builder {
/**
* Configures the appId applied on the [TDS - Debugging and Diagnostics Platform](https://diagnose.woa.com/).
*/
fun setAppId(appId: String): Builder

/**
* Configures the appKey applied on the [TDS - Debugging and Diagnostics Platform](https://diagnose.woa.com/).
*/
fun setAppKey(appKey: String): Builder

/**
* Configures LoggerAdapter for the logging module.
*/
fun setLoggerAdapter(loggerAdapter: LoggerAdapter): Builder

/**
* Inject compliant privacy information (optional; this information is read from android.os.Build by default).
*/
fun setDeviceInfoAdapter(deviceInfoAdapter: DeviceInfoAdapter): Builder

/**
* Custom app version (optional; this information is read from PackageInfo by default).
*/
fun setAppVersion(appVersion: String): Builder

/**
* Configures the tag allowlist.
*/
fun setImportantLabels(vararg labels: String): Builder

/**
* Configures the daily traffic quota (optional; unlimited by default).
*
* @param total Total traffic (unit: bytes). The value must be greater than or equal to [metered].
* @param metered 4G traffic (unit: bytes). The value must be greater than 0.
*/
fun setTrafficQuota(total: Long, metered: Long): Builder

/**
* Configures the automatic reporting frequency limit (optional; unlimited by default).
*
* @param limit Frequency limit.
* @param period Period.
* @param timeUnit Period unit.
*/
fun setUploadCountLimit(limit: Long, period: Long, timeUnit: TimeUnit): Builder

/**
* Configures the environment (optional).
*
* @param env Default value: [TDDiagConfig.ENV_NORMAL]. Value for global edition: [TDDiagConfig.ENV_OVERSEAS].
*/
fun setEnvironment(env: String): Builder

/**
* Generates [TDDiagConfig].
*/
fun build(): TDDiagConfig

}

UploadParam

The UploadParam class is a parameter configuration class for proactive log uploads. You can use its constructor and a series of methods to configure upload-related parameters such as tags, log time range, attached files, additional information, and callbacks.
/**
* Proactive upload parameter class.
*/
class UploadParam {
/**
* @param label Tag. This is required and cannot exceed 64 bytes.
*/
constructor(label: String)

/**
* Configures the log range.
*
* @param startTimestamp Starting timestamp (unit: seconds). This value is included.
* @param endTimestamp Ending timestamp (unit: seconds). This value is not included.
*/
fun setTimestamp(startTimestamp: Long, endTimestamp: Long): UploadParam

/**
* Configures the list of attached files (or folders).
*/
fun setExtraPaths(pathList: List<String>): UploadParam

/**
* Configures the list of attached files (or folders).
*/
fun setExtraFiles(fileList: List<File>): UploadParam

/**
* Configures additional information.
*
* @param summary Summary. This cannot exceed 256 bytes and can be searched.
* @param extraInfo Additional information.
*/
fun setExtraInfo(summary: String?, extraInfo: String?): UploadParam

/**
* Configures the UI callback.
*
* @param listener UI callback.
* @param disableAsyncRetry Indicates whether to disable retry. The default value is false. Set it to true to customize the retry method at the upper layer.
*/
fun setListener(listener: UploadListener?, disableAsyncRetry: Boolean): UploadParam

/**
* Configures whether to only synchronously save the task and upload data on the next startup.
*/
fun setSaveSync(saveSync: Boolean = true): UploadParam

/**
* Configures the file size limit (before compression). This is effective when the value is less than the [limits](README.md).
*/
fun setSizeLimit(sizeLimit: Long): UploadParam

/**
* Configures whether to collect log cache files. Cache files are not collected by default.
*/
fun setIncludeCache(includeCache: Boolean = true): UploadParam

/**
* Additional search information for platform interoperability (cross-system search).
*
* @param queryKey Key used to search logs. The value cannot exceed 128 bytes.
* @param source Caller source. The value cannot exceed 128 bytes.
*/
fun appendExtQueryInfo(queryKey: String, source: String): UploadParam
}

LoggerAdapter

LoggerAdapter is a log component adapter API that provides features to configure the logging level, obtain log files within a specified time range, force log writes, print the SDK logs, and obtain the public key for log encryption, for adapting log-related operations.
/**
* Log component adapter API.
*/
public interface LoggerAdapter {
/**
* Configures the color level.
*/
void setColorLevel(@LogLevel int level);

/**
* Obtains the log files.
*
* @param startTimestamp Starting timestamp (unit: seconds). This value is included.
* @param endTimestamp Ending timestamp (unit: seconds). This value is not included.
* @return List of log files.
*/
@Nullable
List<File> getLogFiles(long startTimestamp, long endTimestamp);

/**
* Obtains the log files.
*
* @param startTimestamp Starting timestamp (unit: seconds). This value is included.
* @param endTimestamp Ending timestamp (unit: seconds). This value is not included.
* @param includeCache Indicates whether to collect cache files.
* @return List of log files.
*/
@Nullable
default List<File> getLogFiles(long startTimestamp, long endTimestamp, boolean includeCache) {
return getLogFiles(startTimestamp, endTimestamp);
}

/**
* Forces to write logs to files.
*/
void flushLog();

/**
* Prints the SDK logs.
*/
void printDiagnoseLog(@NotNull String tag, @NotNull String msg, @Nullable Throwable tr);

/**
* Obtains the log encryption public key (optional; the default value is null, which indicates that encryption is not enabled).
*/
@Nullable
default String getPubKey() {
return null;
}

}

DeviceInfoAdapter

DeviceInfoAdapter is a privacy information adapter API used to provide device brand (corresponding to Build.BRAND) and device model (corresponding to Build.MODEL) information required for privacy compliance.
/**
* Privacy information adapter API.
*/
interface DeviceInfoAdapter {
/**
* {@link android.os.Build#BRAND}
*/
fun getBrand(): String

/**
* {@link android.os.Build#MODEL}
*/
fun getModel(): String
}

UploadListener

UploadListener is a callback interface for the log upload process, which triggers the corresponding callback when the upload starts, progress updates, upload succeeds, or upload fails (returning the specific failure reason) to provide information about the upload status.
interface UploadListener {
/**
* Upload starts.
*/
fun onStart()

/**
* Progress updates. This callback may trigger 0 or multiple times.
*
* @param percent 0–100.
*/
fun onProgress(percent: Int)

/**
* Upload succeeds.
*/
fun onSuccess()

/**
* Upload fails.
*
* @param reason Failure reason:
* * -4: Local restriction policy, including frequency limit, traffic limit, and circuit breaker.
* * -3: Failure to synchronize the upload URL to the backend, usually due to network fluctuations.
* * -2: Tag sampling limit configured on the console.
* * -1: Repetitive task.
* * 1: File upload network error.
* * 2: Compressed log file size exceeds the threshold.
* * 3: Compression IO error, usually due to insufficient storage.
* * 4: During file upload, the Cloud Object Storage (COS) backend returns an HTTP error.
* * 5: No local logs.
*/
fun onFailure(@UploadLogFailReasonType reason: Int)

Logger

Logger is the log component, which is responsible for standardized output, storage, and management of logs. Below are the detailed API descriptions.

TDLog

The TDLog class provides features, such as log system initialization, sub-instance creation, printing logs at different levels (such as VERBOSE and DEBUG), log flushing, and closing and obtaining the default log adapter instance, for log management and output.
public class TDLog {

/**
* Initialization.
*/
public static void initialize(Context context, TDLogConfig config)

/**
* Creates a sub-instance.
*/
public static ILogInstance getSubInstance(String category, boolean consoleLog, int maxAliveDay, long maxAliveFileSize)

/**
* Obtains the default {@link LoggerAdapter} instance.
*/
public static ITDLog getLogImpl()

/**
* Prints {@link LogLevel#VERBOSE} logs.
*/
public static void v(String tag, String message)

/**
* Prints {@link LogLevel#VERBOSE} logs.
*/
public static void v(String tag, String message, Throwable throwable)

/**
* Prints {@link LogLevel#DEBUG} logs.
*/
public static void d(String tag, String message)

/**
* Prints {@link LogLevel#DEBUG} logs.
*/
public static void d(String tag, String message, Throwable throwable)

/**
* Prints {@link LogLevel#INFO} logs.
*/
public static void i(String tag, String message)

/**
* Prints {@link LogLevel#INFO} logs.
*/
public static void i(String tag, String message, Throwable throwable)

/**
* Prints {@link LogLevel#WARN} logs.
*/
public static void w(String tag, String message)

/**
* Prints {@link LogLevel#WARN} logs.
*/
public static void w(String tag, String message, Throwable throwable)

/**
* Prints {@link LogLevel#ERROR} logs.
*/
public static void e(String tag, String message)

/**
* Prints {@link LogLevel#ERROR} logs.
*/
public static void e(String tag, String message, Throwable throwable)

/**
* Prints {@link TDLogInfo} logs.
*/
public static void log(TDLogInfo info)

/**
* Forces to write buffer logs to files.
*/
public static void flushLog()

/**
* Closes the log instance.
*/
public static void closeLog()
}

TDLogConfig.Build

TDLogConfig.Builder is the configuration builder for the logging component. You can use chained methods to configure parameters such as the log level, storage path, encryption public key, file size, retention days, and whether to output to Logcat, ultimately generating a TDLogConfig instance.
/**
* Log component configuration builder.
*/
public static class TDLogConfig.Build {

/**
* constructor
*/
public Builder(Context context)

/**
* Configures the lowest log level.
*/
public Builder setLogLevel(@LogLevel int logLevel)

/**
* Configures whether to output to Logcat.
*/
public Builder setConsoleLog(boolean consoleLog)

/**
* Configures the log file storage path.
*/
public Builder setLogPath(String logPath)

/**
* Configures the public key for log file encryption.
*/
public Builder setPubKey(String key)

/**
* Configures the maximum size of a single log file.
*/
public Builder setMaxFileSize(long maxFileSize)

/**
* Configures the retention days for log files.
*/
public Builder setMaxAliveDay(int maxAliveDay)

/**
* Configures the maximum total size of log files.
*/
public Builder setMaxAliveFileSize(long maxAliveFileSize)

/**
* Creates a {@link TDLogConfig} instance.
*/
public TDLogConfig build()
}

TDLogInfo

The TDLogInfo class is a class that holds log information. It is used to encapsulate detailed log data such as tags (including primary, secondary, and tertiary tags), level, thread information, content, exception object, and timestamp.
public class TDLogInfo {
/**
* Tag
*/
public String tag;
/**
* Secondary tag.
*/
public String subTag;
/**
* Tertiary tag.
*/
public String thirdTag;
/**
* Log level.
*/
@LogLevel
public int level;
/**
* Thread ID.
*/
public long tid;
/**
* Thread name.
*/
public String tName;
/**
* Log content.
*/
public String message;
/**
* Throwable object.
*/
public Throwable throwable;
/**
* Time, in milliseconds. The default value is 0, which indicates unspecified.
*/
public long timeMillis;
}

ILogInstance

ILogInstance is a log instance API that provides features to print logs (including regular logs and logs with custom information), force writing logs to files, and close the current log instance.
/**
* Log instance API.
*/
public interface ILogInstance {

/**
* Prints logs.
*/
void log(String tag, @LogLevel int level, String message, @Nullable Throwable throwable);

/**
* Prints logs with custom information.
*/
void log(TDLogInfo info);

/**
* Forces to write logs to files.
*/
void flushLog();

/**
* Closes the current log instance.
*/
void closeLog();
}

Push Support (Optional)

The log SDK pulls configurations during initialization by default and checks for log retrieval commands. With push features integrated, the SDK can receive log retrieval commands faster, reducing waiting time.
You need to integrate your own push channels with the platform (the platform does not provide push capabilities). After a log retrieval or log coloring push request is received, you can call the following API to complete log retrieval or coloring.
TDDiag.onPush("{}");

Proactive Command Issuance Checking (Optional)

Under normal circumstances, setting the userId during startup and integrating push requests can ensure excellent real-time performance for the issuance of retrieval command configurations. If the app requires additional opportunities to check for command configuration issuance (such as when the app comes to the foreground), you can call this API at the appropriate time.
TDDiag.syncConfig(false); // False indicates a non-forced refresh.
The SDK has a frequency limit for the proactive command configuration issuance checks, and the limitation policy is dynamically determined by the backend based on load.
Note:
It is not recommended to perform forced refresh in any automatically triggered scenario without user interaction, to avoid imposing uncontrollable load pressure on the backend.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback