interface.uts 2.5 KB
export type IData = string | number | boolean | Array<any> | UTSJSONObject | null | undefined


/**
 * 上传文件参数的参数
 * @param serverUrl 上传接口
 * @param headers 请求头参数
 * @param parameters 附加的表单参数
 * @param timeout 接口超时时间
 * @param include 是否包含系统日志`log_apps.log`
 * @param days 上传近几天的日志
 * @param suffix 上传时使用的文件后缀,uploadLog 使用,默认 "log";uploadZip 使用,默认 "zip"
 */
export type IUpload = {
	serverUrl : string
	headers ?: UTSJSONObject | null 
	parameters ?: UTSJSONObject | null 
	timeout ?: number
	include ?: boolean
	days ?: number
	suffix ?: string
}


/**
 * 返回的参数
 * @param success 是否成功
 * @param message 描述
 * @param data 数据
 */
export type IReturn = {
	success : boolean
	message : string
	data ?: IData
}

/** 初始化自动收集应用日志;可选参数 logFileMode:LOG_FILE_MODE_DAY(0) 按天,LOG_FILE_MODE_HOUR(1) 按小时,不传默认按天 */
export type initLog = (logFileMode ?: Number) => Promise<IReturn>

/** 设置用户标识 */
export type setUser = (user : String) => Promise<IReturn>

/** 设置标签 */
export type setTag = (tag : String) => Promise<IReturn>

/** 记录一般日志 */
export type logInfo = (msg : String) => Promise<IReturn>

/** 记录警告日志 */
export type logWarn = (msg : String) => Promise<IReturn>

/** 记录错误日志 */
export type logError = (msg : String) => Promise<IReturn>

/** 记录用户行为/事件日志 */
export type logUser = (msg : String, type ?: String) => Promise<IReturn>

/** 记录系统/应用日志 */
export type logApp = (msg : String, type ?: String) => Promise<IReturn>

/** 获取本地日志文件列表 */
export type getLogFiles = (include ?: Boolean) => Promise<IReturn>

/** 清理过期日志文件 */
export type cleanLogs = (keepDay ?: Number) => Promise<IReturn>

/** 上传日志文件 */
export type uploadLog = (options : IUpload, onCallback ?: (result : IReturn) => void) => Promise<IReturn>

/** 压缩并上传日志文件 */
export type uploadZip = (options : IUpload, onCallback ?: (result : IReturn) => void) => Promise<IReturn>

/** 上传指定单个文件 */
export type uploadFile = (filePath : String, options : IUpload, uploadFileName ?: String | null, onCallback ?: (result : IReturn) => void) => Promise<IReturn>

/** 压缩指定文件夹并上传 */
export type uploadFolder = (folderPath : String, options : IUpload, onCallback ?: (result : IReturn) => void) => Promise<IReturn>