1e41f4b71Sopenharmony_ci# HiLog\_Lite Development<a name="EN-US_TOPIC_0000001185815838"></a> 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview<a name="section775017517390"></a> 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciHiLog\_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. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Available APIs<a name="section114412157402"></a> 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciHiLog\_lite provides the following C APIs: 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci``` 12e41f4b71Sopenharmony_ciHILOG_DEBUG(mod, fmt, ...) 13e41f4b71Sopenharmony_ciHILOG_INFO/HILOG_WARN/HILOG_ERROR/HILOG_FATAL 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**Table 1** Parameters of C APIs 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci<a name="table998125624816"></a> 19e41f4b71Sopenharmony_ci<table><thead align="left"><tr id="row10981135611481"><th class="cellrowborder" valign="top" width="11.57%" id="mcps1.2.5.1.1"><p id="p11981145674811"><a name="p11981145674811"></a><a name="p11981145674811"></a>Parameter</p> 20e41f4b71Sopenharmony_ci</th> 21e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="11.83%" id="mcps1.2.5.1.2"><p id="p39821456124810"><a name="p39821456124810"></a><a name="p39821456124810"></a>Mandatory?</p> 22e41f4b71Sopenharmony_ci</th> 23e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="15.21%" id="mcps1.2.5.1.3"><p id="p139822056104811"><a name="p139822056104811"></a><a name="p139822056104811"></a>Data Type</p> 24e41f4b71Sopenharmony_ci</th> 25e41f4b71Sopenharmony_ci<th class="cellrowborder" valign="top" width="61.39%" id="mcps1.2.5.1.4"><p id="p3982145618482"><a name="p3982145618482"></a><a name="p3982145618482"></a>Description</p> 26e41f4b71Sopenharmony_ci</th> 27e41f4b71Sopenharmony_ci</tr> 28e41f4b71Sopenharmony_ci</thead> 29e41f4b71Sopenharmony_ci<tbody><tr id="row209821456144818"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.2.5.1.1 "><p id="p20982125616483"><a name="p20982125616483"></a><a name="p20982125616483"></a>mod</p> 30e41f4b71Sopenharmony_ci</td> 31e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.2.5.1.2 "><p id="p1298245634810"><a name="p1298245634810"></a><a name="p1298245634810"></a>Yes</p> 32e41f4b71Sopenharmony_ci</td> 33e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.2.5.1.3 "><p id="p1198295634817"><a name="p1198295634817"></a><a name="p1198295634817"></a>uint8</p> 34e41f4b71Sopenharmony_ci</td> 35e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.2.5.1.4 "><p id="p0982145634817"><a name="p0982145634817"></a><a name="p0982145634817"></a>Indicates the module or service ID.</p> 36e41f4b71Sopenharmony_ci<p id="p1982155664820"><a name="p1982155664820"></a><a name="p1982155664820"></a>IDs are planned and assigned in a unified manner. A maximum of 64 IDs are supported. Third-party applications use <strong id="b14339112165018"><a name="b14339112165018"></a><a name="b14339112165018"></a>HILOG_MODULE_APP</strong> as their module ID.</p> 37e41f4b71Sopenharmony_ci</td> 38e41f4b71Sopenharmony_ci</tr> 39e41f4b71Sopenharmony_ci<tr id="row1898225611489"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.2.5.1.1 "><p id="p9982656164812"><a name="p9982656164812"></a><a name="p9982656164812"></a>fmt</p> 40e41f4b71Sopenharmony_ci</td> 41e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.2.5.1.2 "><p id="p998255616484"><a name="p998255616484"></a><a name="p998255616484"></a>Yes</p> 42e41f4b71Sopenharmony_ci</td> 43e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.2.5.1.3 "><p id="p18982256194818"><a name="p18982256194818"></a><a name="p18982256194818"></a>char *</p> 44e41f4b71Sopenharmony_ci</td> 45e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.2.5.1.4 "><p id="p2982165664818"><a name="p2982165664818"></a><a name="p2982165664818"></a>Indicates the format specifier for output.</p> 46e41f4b71Sopenharmony_ci<a name="ol19982256164816"></a><a name="ol19982256164816"></a><ol id="ol19982256164816"><li>A maximum of six variable parameters are supported. <strong id="b774813235502"><a name="b774813235502"></a><a name="b774813235502"></a>%s</strong> is not supported.</li><li>The maximum length of a formatted log record is 128 bytes. If the maximum length is exceeded, the log cannot be printed.</li></ol> 47e41f4b71Sopenharmony_ci</td> 48e41f4b71Sopenharmony_ci</tr> 49e41f4b71Sopenharmony_ci<tr id="row16982105613488"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.2.5.1.1 "><p id="p1898225604813"><a name="p1898225604813"></a><a name="p1898225604813"></a>Variable parameters</p> 50e41f4b71Sopenharmony_ci</td> 51e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.2.5.1.2 "><p id="p1698217568486"><a name="p1698217568486"></a><a name="p1698217568486"></a>No</p> 52e41f4b71Sopenharmony_ci</td> 53e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.2.5.1.3 "><p id="p189834566489"><a name="p189834566489"></a><a name="p189834566489"></a>int32</p> 54e41f4b71Sopenharmony_ci</td> 55e41f4b71Sopenharmony_ci<td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.2.5.1.4 "><p id="p9983175654814"><a name="p9983175654814"></a><a name="p9983175654814"></a>Only numeric types are supported. A maximum of six variable parameters are allowed.</p> 56e41f4b71Sopenharmony_ci</td> 57e41f4b71Sopenharmony_ci</tr> 58e41f4b71Sopenharmony_ci</tbody> 59e41f4b71Sopenharmony_ci</table> 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci## How to Develop<a name="section1482812550419"></a> 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciThe following provides an example of how the Samgr\_Lite module uses the HiLog\_Lite framework. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci1. 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**. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci ``` 68e41f4b71Sopenharmony_ci typedef enum { 69e41f4b71Sopenharmony_ci ... 70e41f4b71Sopenharmony_ci HILOG_MODULE_SAMGR, 71e41f4b71Sopenharmony_ci ... 72e41f4b71Sopenharmony_ci } HiLogModuleType; 73e41f4b71Sopenharmony_ci ``` 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci2. Register the module. Specifically, add the registration code to the **HiLogInit** function in **base/hiviewdfx/hilog\_lite/frameworks/mini/hiview\_log.c**. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci ``` 78e41f4b71Sopenharmony_ci HiLogRegisterModule(HILOG_MODULE_SAMGR, "SAMGR"); 79e41f4b71Sopenharmony_ci ``` 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci3. Add the header file dependencies to the **foundation/systemabilitymgr/samgr\_lite/samgr/BUILD.gn** file. 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci ``` 84e41f4b71Sopenharmony_ci include_dirs = [ 85e41f4b71Sopenharmony_ci "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", 86e41f4b71Sopenharmony_ci ] 87e41f4b71Sopenharmony_ci ``` 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci4. Reference the header file in the **foundation/systemabilitymgr/samgr\_lite/samgr/source/message.c** file and call the related APIs. 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci ``` 92e41f4b71Sopenharmony_ci #include <log.h> 93e41f4b71Sopenharmony_ci uint32 *SAMGR_SendSharedRequest(const Identity *identity, const Request *request, uint32 *token, Handler handler) 94e41f4b71Sopenharmony_ci { 95e41f4b71Sopenharmony_ci ... 96e41f4b71Sopenharmony_ci if (err != EC_SUCCESS) { 97e41f4b71Sopenharmony_ci HILOG_ERROR(HILOG_MODULE_SAMGR, "SharedSend [%p] failed(%d)!", identity->queueId, err); 98e41f4b71Sopenharmony_ci (void)FreeReference(&exchange); 99e41f4b71Sopenharmony_ci } 100e41f4b71Sopenharmony_ci ... 101e41f4b71Sopenharmony_ci } 102e41f4b71Sopenharmony_ci ``` 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci 105