Development Guidelines on HiLog_lite
Overview
HiLog_lite is the HiLog framework for Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB). 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/distributedschedule/samgr_lite/samgr/BUILD.gn file.
include_dirs = [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", ]
-
Reference the header file in the foundation/distributedschedule/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); } ... }