package com.dong.demo013

import kotlinx.cinterop.ExperimentalForeignApi
import platform.PerformanceAnalysisKit.HiLog.OH_LOG_Print
import kotlin.experimental.ExperimentalNativeApi

@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg")
fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: String): Int {
    return try {
        OH_LOG_Print(type, level, domain, tag, message)
    } catch (_: Throwable) {
        -1
    }

}

actual fun pirntSingleHiLog(){
    hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "单次日志打印-高亮");

}

actual fun pirntAllLevelHiLog(){
// 输出 DEBUG 级别
    // LOG_APP = 0 (应用日志类型)
    // LOG_DEBUG = 3 (调试级别)
    // domain = 0x1234 (任意自定义值，范围0x0000-0xFFFF)
    // tag = "TestTag" (自定义标签)
    hiLogPrintMsg(0u, 3u, 4660u, "TestTag", "This is a DEBUG log from PrintMsg");

    // 输出 INFO 级别
    // LOG_INFO = 4 (信息级别)
    hiLogPrintMsg(0u, 4u, 4660u, "TestTag", "This is an INFO log from PrintMsg");

    // 输出 WARN 级别
    // LOG_WARN = 5 (警告级别)
    hiLogPrintMsg(0u, 5u, 4660u, "TestTag", "This is a WARN log from PrintMsg");

    // 输出 ERROR 级别
    // LOG_ERROR = 6 (错误级别)
    hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "This is an ERROR log from PrintMsg");

    // 输出 FATAL 级别
    // LOG_FATAL = 7 (致命级别)
    hiLogPrintMsg(0u, 7u, 4660u, "TestTag", "This is a FATAL log from PrintMsg");
}


actual fun pirntRandomHiLog(){
    hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
}

@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("testArkTsToKotin")
actual fun testArkTsToKotin() {
    print("测试ArkTs至Kotlin单向跳转")
}

actual fun triggerANRByInfiniteLoop() {
    while (true){

    }
}