# 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

Parameter

Mandatory?

Data Type

Description

mod

Yes

uint8

Indicates the module or service ID.

IDs are planned and assigned in a unified manner. A maximum of 64 IDs are supported. Third-party applications use HILOG_MODULE_APP as their module ID.

fmt

Yes

char *

Indicates the format specifier for output.

  1. A maximum of six variable parameters are supported. %s is not supported.
  2. The maximum length of a formatted log record is 128 bytes. If the maximum length is exceeded, the log cannot be printed.

Variable parameters

No

int32

Only numeric types are supported. A maximum of six variable parameters are allowed.

## How to Develop The following provides an example of how the Samgr\_Lite module uses the HiLog\_Lite framework. 1. 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; ``` 2. 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"); ``` 3. 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", ] ``` 4. Reference the header file in the **foundation/systemabilitymgr/samgr\_lite/samgr/source/message.c** file and call the related APIs. ``` #include 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); } ... } ```