# KLogDemo **Repository Path**: xuvw/klog-demo ## Basic Information - **Project Name**: KLogDemo - **Description**: No description available - **Primary Language**: TypeScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-12-16 - **Last Updated**: 2025-02-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # KLogDemo #### 介绍 KLog:HarmonyOS NEXT 上一个日志拦截组件,支持全局hilog日志拦截(ArkTS&NDK)回调 #### 使用说明 - 1、引入: ``` "@xuvw/klog": "1.0.2" ``` - 2、使用: ``` import { hilog } from '@kit.PerformanceAnalysisKit'; //导入KLog import logger, { KLogView } from '@xuvw/klog'; import testNapi from 'libentry.so'; const TAG: string = "[ArkTS]" @Entry @Component struct Index { @State message: string = 'Hello World'; build() { Column() { this.napiDemo() //日志展示组件 KLogView({domain:0xff01}).width('100%').height('80%') }.height('100%') } @Builder napiDemo() { Column() { Text(this.message).fontSize(50).fontWeight(FontWeight.Bold) .onClick(() => { //系统hilog hilog.info(0xFF01, TAG, 'Test NAPI 2 + 3 = %{public}d', testNapi.add(2, 3)); //KLog logger.i(TAG, "hello KLog"); }) }.justifyContent(FlexAlign.Center).height('20%') } } ``` - 3、效果: