harmony 鸿蒙HiLog_Lite Development
HiLog_Lite Development
Overview
HiLog_Lite is the HiLog framework for Mini-System Devices (reference memory ≥ 128 KiB) and Small-System Devices (reference memory ≥ 1 MiB). It implements functions such as log printing, log output, and flow control.
Available APIs
HiLog_lite provides the following C APIs:
HILOG_DEBUG(mod, fmt, ...)
HILOG_INFO/HILOG_WARN/HILOG_ERROR/HILOG_FATAL
Table 1 Parameters of C APIs
How to Develop
The following provides an example of how the Samgr_Lite module uses the HiLog_Lite framework.
Add the module ID, and define HILOG_MODULE_SAMGR in the HiLogModuleType structure in base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite/hiview_log.h.
typedef enum { ... HILOG_MODULE_SAMGR, ... } HiLogModuleType;
Register the module. Specifically, add the registration code to the HiLogInit function in base/hiviewdfx/hilog_lite/frameworks/mini/hiview_log.c.
HiLogRegisterModule(HILOG_MODULE_SAMGR, "SAMGR");
Add the header file dependencies to the foundation/systemabilitymgr/samgr_lite/samgr/BUILD.gn file.
include_dirs = [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", ]
Reference the header file in the foundation/systemabilitymgr/samgr_lite/samgr/source/message.c file and call the related APIs.
#include <log.h> uint32 *SAMGR_SendSharedRequest(const Identity *identity, const Request *request, uint32 *token, Handler handler) { ... if (err != EC_SUCCESS) { HILOG_ERROR(HILOG_MODULE_SAMGR, "SharedSend [%p] failed(%d)!", identity->queueId, err); (void)FreeReference(&exchange); } ... }
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AI Framework Development Guide
harmony 鸿蒙NNRt Access Adaptation
harmony 鸿蒙Application Privilege Configuration
harmony 鸿蒙Setting Up a Development Environment
harmony 鸿蒙Development Guidelines
harmony 鸿蒙Application Framework Overview
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦