• Home
Name Date Size #Lines LOC

..--

command/12-May-2024-361287

figures/12-May-2024-

frameworks/12-May-2024-3,9653,134

interfaces/native/12-May-2024-1,338328

services/12-May-2024-450366

test/12-May-2024-853462

LICENSED12-May-20249.9 KiB177150

README.mdD12-May-202425.6 KiB304242

README_zh.mdD12-May-202416.9 KiB258200

README.md

1# Hilog\_lite<a name="EN-US_TOPIC_0000001078674780"></a>
2
3-   [Introduction](#s9c9ad6e6d5494719ad0f6630a0a1add4)
4-   [Directory Structure](#s4edd47ec6791449aa2d6362fed84325e)
5-   [Constraints](#s7f347323ea45437ca31edae5c10f2991)
6-   [Log Function for the Mini System](#sd6e99f792bc942f9bb5aa92111be7aff)
7-   [Small System](#s33e0a62bc1dd4a2a9578fc22bd023f11)
8-   [Repositories Involved](#s999c697ebde345449386ce8dc1df1db0)
9
10## Introduction<a name="s9c9ad6e6d5494719ad0f6630a0a1add4"></a>
11
12Hilog\_lite provides the log function of the DFX subsystem for the mini and small systems.
13
14## Directory Structure<a name="s4edd47ec6791449aa2d6362fed84325e"></a>
15
16**Table  1**  Directory structure for Hilog\_lite in the DFX subsystem
17
18<a name="ta443dcf0f0dd4e07834b95e031c9fb12"></a>
19<table><thead align="left"><tr id="ra41be074cf4949d284a843a90e781f33"><th class="cellrowborder" valign="top" width="30.34%" id="mcps1.2.3.1.1"><p id="a727aecc17b674751a9d5d7ebdd391310"><a name="a727aecc17b674751a9d5d7ebdd391310"></a><a name="a727aecc17b674751a9d5d7ebdd391310"></a>Directory</p>
20</th>
21<th class="cellrowborder" valign="top" width="69.66%" id="mcps1.2.3.1.2"><p id="ad32d72628b854c53ae4b7c54edfc8afe"><a name="ad32d72628b854c53ae4b7c54edfc8afe"></a><a name="ad32d72628b854c53ae4b7c54edfc8afe"></a>Description</p>
22</th>
23</tr>
24</thead>
25<tbody><tr id="rc4c61aa63a33430fb82263e2bda83e02"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a08bb3cab9f18422bbebabac53be94111"><a name="a08bb3cab9f18422bbebabac53be94111"></a><a name="a08bb3cab9f18422bbebabac53be94111"></a>interfaces/native/kits/hilog</p>
26</td>
27<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a4603eff664a64d7e80db8d890957522c"><a name="a4603eff664a64d7e80db8d890957522c"></a><a name="a4603eff664a64d7e80db8d890957522c"></a>Defines external APIs that provide the log function for the small system.</p>
28</td>
29</tr>
30<tr id="rf932828a7faa477e894fc6ac1405c5c2"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="aa165ba46894b44e396163892a274c308"><a name="aa165ba46894b44e396163892a274c308"></a><a name="aa165ba46894b44e396163892a274c308"></a>interfaces/native/kits/hilog_lite</p>
31</td>
32<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="af97241f84b4649de924f32608d0298da"><a name="af97241f84b4649de924f32608d0298da"></a><a name="af97241f84b4649de924f32608d0298da"></a>Defines external APIs that provide the log function for the mini system.</p>
33</td>
34</tr>
35<tr id="r81c09daddf724dc088992dc6fb5caeae"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a915128b09aeb4e25b1f7aba042c42459"><a name="a915128b09aeb4e25b1f7aba042c42459"></a><a name="a915128b09aeb4e25b1f7aba042c42459"></a>services/hilogcat</p>
36</td>
37<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a7645a6df6f164244b3292347b1f7ad04"><a name="a7645a6df6f164244b3292347b1f7ad04"></a><a name="a7645a6df6f164244b3292347b1f7ad04"></a>Stores log-related services and commands for the small system.</p>
38</td>
39</tr>
40<tr id="r4fa9d620df3c4e24bd1a94c79ccabcae"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a95c8bfabb4424e38a11d03a59162ae14"><a name="a95c8bfabb4424e38a11d03a59162ae14"></a><a name="a95c8bfabb4424e38a11d03a59162ae14"></a>services/apphilogcat</p>
41</td>
42<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a25c0853c8d0446839ea2b900856696cd"><a name="a25c0853c8d0446839ea2b900856696cd"></a><a name="a25c0853c8d0446839ea2b900856696cd"></a>Provides the log flushing service for the small system.</p>
43</td>
44</tr>
45<tr id="r0a82ab924ac24725bcb24cf3fa523010"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="aba63f8bc7c0a469f94e6f8d177b5c91c"><a name="aba63f8bc7c0a469f94e6f8d177b5c91c"></a><a name="aba63f8bc7c0a469f94e6f8d177b5c91c"></a>command</p>
46</td>
47<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a1f274cd4df2949589ebe8a29c4e9a241"><a name="a1f274cd4df2949589ebe8a29c4e9a241"></a><a name="a1f274cd4df2949589ebe8a29c4e9a241"></a>Provides log query commands for the mini system.</p>
48</td>
49</tr>
50<tr id="rb359a73bb38e47c8952cf3a809b7d38d"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"><a name="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"></a><a name="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"></a>frameworks/featured</p>
51</td>
52<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a307bdb53cf7545d4bd663fb62dd0ca38"><a name="a307bdb53cf7545d4bd663fb62dd0ca38"></a><a name="a307bdb53cf7545d4bd663fb62dd0ca38"></a>Implements the APIs that provide the log function for the small system.</p>
53</td>
54</tr>
55<tr id="rbb7fc424f05a4df181595f633455e8a8"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a32392112d5b04f7e8baceca6353b9ecf"><a name="a32392112d5b04f7e8baceca6353b9ecf"></a><a name="a32392112d5b04f7e8baceca6353b9ecf"></a>frameworks/mini</p>
56</td>
57<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="af1f91dea1e6b46dd983e659f936f22a7"><a name="af1f91dea1e6b46dd983e659f936f22a7"></a><a name="af1f91dea1e6b46dd983e659f936f22a7"></a>Implements the APIs that provide the log function for the mini system.</p>
58</td>
59</tr>
60</tbody>
61</table>
62
63## Constraints<a name="s7f347323ea45437ca31edae5c10f2991"></a>
64
65The overall code of the mini system is developed based on the C standard library.
66
67## Log Function for the Mini System<a name="sd6e99f792bc942f9bb5aa92111be7aff"></a>
68
69-   To add a module \(for example, Module A\) and print logs, perform the following steps:
70    1.  **Add the module ID.**
71
72        Add  **HILOG\_MODULE\_A**  to  **base/hiviewdfx/interfaces/hilog\_lite/interfaces/native/kits/hilog\_lite**.
73
74        ```
75        typedef enum {
76            /** DFX */
77            HILOG_MODULE_HIVIEW = 0,
78            /** System Module A */
79            HILOG_MODULE_A,
80            /** Maximum number of modules */
81            HILOG_MODULE_MAX
82        } HiLogModuleType;
83        ```
84
85
86    1.  **Register the module.**
87
88        Add the following code to the initialization process of Module A to register it with the log framework:
89
90        ```
91        HiLogRegisterModule(HILOG_MODULE_A, "A");
92        ```
93
94
95    1.  **Modify the static configuration of the DFX framework.**
96
97        Modify  **g\_hiviewConfig**  in the following file as required. By default, modification is not required and logs are output to the serial port.
98
99        ```
100        utils/lite/hiview_config.c
101        ```
102
103        <a name="td247e4651b964f66b48433481b4d4ec3"></a>
104        <table><thead align="left"><tr id="r2d18b74da660408380d46a6048a9e8be"><th class="cellrowborder" valign="top" width="25.180000000000003%" id="mcps1.1.3.1.1"><p id="a3d342605963b49f0bbc054a45a0f6c33"><a name="a3d342605963b49f0bbc054a45a0f6c33"></a><a name="a3d342605963b49f0bbc054a45a0f6c33"></a>Configuration Item</p>
105        </th>
106        <th class="cellrowborder" valign="top" width="74.82%" id="mcps1.1.3.1.2"><p id="a40c1ea12a15d43d6b53412f1db99cf3d"><a name="a40c1ea12a15d43d6b53412f1db99cf3d"></a><a name="a40c1ea12a15d43d6b53412f1db99cf3d"></a>Description</p>
107        </th>
108        </tr>
109        </thead>
110        <tbody><tr id="re41b7052898d4451a271af54fc0444c9"><td class="cellrowborder" valign="top" width="25.180000000000003%" headers="mcps1.1.3.1.1 "><p id="ade652f31f1924b89a6043e0d8f2e2f8e"><a name="ade652f31f1924b89a6043e0d8f2e2f8e"></a><a name="ade652f31f1924b89a6043e0d8f2e2f8e"></a>outputOption</p>
111        </td>
112        <td class="cellrowborder" valign="top" width="74.82%" headers="mcps1.1.3.1.2 "><p id="a831cff5b5e4640bba83434a0eb26c2e8"><a name="a831cff5b5e4640bba83434a0eb26c2e8"></a><a name="a831cff5b5e4640bba83434a0eb26c2e8"></a>Log output mode. The value can be:</p>
113        <a name="ul11276181319272"></a><a name="ul11276181319272"></a><ul id="ul11276181319272"><li><strong id="b1027691316279"><a name="b1027691316279"></a><a name="b1027691316279"></a>OUTPUT_OPTION_DEBUG</strong>: Logs are directly output to the serial port without cross-task scheduling. This value is used only for temporary debugging.</li></ul>
114        <a name="ul659914264273"></a><a name="ul659914264273"></a><ul id="ul659914264273"><li><strong id="b1359818268279"><a name="b1359818268279"></a><a name="b1359818268279"></a>OUTPUT_OPTION_FLOW</strong> (default value): Logs are output as data flow to the serial port.</li></ul>
115        <a name="ul283283282711"></a><a name="ul283283282711"></a><ul id="ul283283282711"><li><strong id="b18831133217271"><a name="b18831133217271"></a><a name="b18831133217271"></a>OUTPUT_OPTION_TEXT_FILE</strong>: Logs are output as text files.</li></ul>
116        </td>
117        </tr>
118        <tr id="rd29a278d00134ad4af1dde3b0957bf1e"><td class="cellrowborder" valign="top" width="25.180000000000003%" headers="mcps1.1.3.1.1 "><p id="a0930c997c3724317a1de154038668048"><a name="a0930c997c3724317a1de154038668048"></a><a name="a0930c997c3724317a1de154038668048"></a>level</p>
119        </td>
120        <td class="cellrowborder" valign="top" width="74.82%" headers="mcps1.1.3.1.2 "><p id="a60b30c4ddebf41e895ef4eacb832629d"><a name="a60b30c4ddebf41e895ef4eacb832629d"></a><a name="a60b30c4ddebf41e895ef4eacb832629d"></a>Log level for output. Only the logs whose levels are higher than or equal to the level specified by this parameter can be output. The value can be <strong id="en-us_topic_0000001051742157_b388817225412"><a name="en-us_topic_0000001051742157_b388817225412"></a><a name="en-us_topic_0000001051742157_b388817225412"></a>HILOG_LV_DEBUG</strong>, <strong id="en-us_topic_0000001051742157_b1010817302414"><a name="en-us_topic_0000001051742157_b1010817302414"></a><a name="en-us_topic_0000001051742157_b1010817302414"></a>HILOG_LV_INFO</strong>, <strong id="en-us_topic_0000001051742157_b1888283212411"><a name="en-us_topic_0000001051742157_b1888283212411"></a><a name="en-us_topic_0000001051742157_b1888283212411"></a>HILOG_LV_WARN</strong>, <strong id="en-us_topic_0000001051742157_b863582564112"><a name="en-us_topic_0000001051742157_b863582564112"></a><a name="en-us_topic_0000001051742157_b863582564112"></a>HILOG_LV_ERROR</strong>, or <strong id="en-us_topic_0000001051742157_b108501827164112"><a name="en-us_topic_0000001051742157_b108501827164112"></a><a name="en-us_topic_0000001051742157_b108501827164112"></a>HILOG_LV_FATAL</strong>.</p>
121        </td>
122        </tr>
123        <tr id="r6b11c6bf7a0b4937a663ef5ec344ab50"><td class="cellrowborder" valign="top" width="25.180000000000003%" headers="mcps1.1.3.1.1 "><p id="aad1cbc77fa614e36a2481198278ad2d4"><a name="aad1cbc77fa614e36a2481198278ad2d4"></a><a name="aad1cbc77fa614e36a2481198278ad2d4"></a>logSwitch</p>
124        </td>
125        <td class="cellrowborder" valign="top" width="74.82%" headers="mcps1.1.3.1.2 "><p id="ad714e073f17e4f33b5843c01de0a9c87"><a name="ad714e073f17e4f33b5843c01de0a9c87"></a><a name="ad714e073f17e4f33b5843c01de0a9c87"></a>Log switch. The HiLog module can be successfully initialized even if this switch is turned off before compilation. By default, this switch is turned on. The value can be <strong id="en-us_topic_0000001051742157_b860151584911"><a name="en-us_topic_0000001051742157_b860151584911"></a><a name="en-us_topic_0000001051742157_b860151584911"></a>HIVIEW_FEATURE_ON</strong> or <strong id="en-us_topic_0000001051742157_b63541819493"><a name="en-us_topic_0000001051742157_b63541819493"></a><a name="en-us_topic_0000001051742157_b63541819493"></a>HIVIEW_FEATURE_OFF</strong>.</p>
126        </td>
127        </tr>
128        <tr id="re811d5b688a94e2796630e601f0ee6c6"><td class="cellrowborder" valign="top" width="25.180000000000003%" headers="mcps1.1.3.1.1 "><p id="a20d547f657cf49a2b8ab3b4622d4aba0"><a name="a20d547f657cf49a2b8ab3b4622d4aba0"></a><a name="a20d547f657cf49a2b8ab3b4622d4aba0"></a>dumpSwitch</p>
129        </td>
130        <td class="cellrowborder" valign="top" width="74.82%" headers="mcps1.1.3.1.2 "><p id="ab5eef5ce590149438be7393317530fda"><a name="ab5eef5ce590149438be7393317530fda"></a><a name="ab5eef5ce590149438be7393317530fda"></a>Dump switch. If this switch is turned off before compilation, the HiDumper module will not be initialized. By default, this switch is turned off. The value can be <strong id="en-us_topic_0000001051742157_b1139516363532"><a name="en-us_topic_0000001051742157_b1139516363532"></a><a name="en-us_topic_0000001051742157_b1139516363532"></a>HIVIEW_FEATURE_ON</strong> or <strong id="en-us_topic_0000001051742157_b16939113816534"><a name="en-us_topic_0000001051742157_b16939113816534"></a><a name="en-us_topic_0000001051742157_b16939113816534"></a>HIVIEW_FEATURE_OFF</strong>.</p>
131        </td>
132        </tr>
133        <tr id="ra276f7f5a7cb4a0b8449047b5cdff658"><td class="cellrowborder" valign="top" width="25.180000000000003%" headers="mcps1.1.3.1.1 "><p id="ac47f6a11699c401090b9c7b8fdffff30"><a name="ac47f6a11699c401090b9c7b8fdffff30"></a><a name="ac47f6a11699c401090b9c7b8fdffff30"></a>eventSwitch</p>
134        </td>
135        <td class="cellrowborder" valign="top" width="74.82%" headers="mcps1.1.3.1.2 "><p id="a45b2e86aed4848d18c2faaa8c22c6bd3"><a name="a45b2e86aed4848d18c2faaa8c22c6bd3"></a><a name="a45b2e86aed4848d18c2faaa8c22c6bd3"></a>Event output switch. If this switch is turned off before compilation, the HiEvent module will not be initialized. By default, this switch is turned off. The value can be <strong id="en-us_topic_0000001051742157_b146761815543"><a name="en-us_topic_0000001051742157_b146761815543"></a><a name="en-us_topic_0000001051742157_b146761815543"></a>HIVIEW_FEATURE_ON</strong> or <strong id="en-us_topic_0000001051742157_b1816422311548"><a name="en-us_topic_0000001051742157_b1816422311548"></a><a name="en-us_topic_0000001051742157_b1816422311548"></a>HIVIEW_FEATURE_OFF</strong>.</p>
136        </td>
137        </tr>
138        </tbody>
139        </table>
140
141    2.  **Print logs.**
142
143        Include  **\#include "log.h"**  in the  **.c**  file where logs need to be printed. Call the following API:
144
145        HILOG\_INFO\(HILOG\_MODULE\_A, "log test: %d", 88\);
146
147        The following table describes the parameters in the API.
148
149        <a name="tb0e7329d09184f109c0cae274325b2f1"></a>
150        <table><thead align="left"><tr id="r74cdd06495cb4915ad894e023deff4b2"><th class="cellrowborder" valign="top" width="11.57%" id="mcps1.1.5.1.1"><p id="a8cfadf9da95144fd8a9eb9dbd1362b89"><a name="a8cfadf9da95144fd8a9eb9dbd1362b89"></a><a name="a8cfadf9da95144fd8a9eb9dbd1362b89"></a>Parameter</p>
151        </th>
152        <th class="cellrowborder" valign="top" width="11.83%" id="mcps1.1.5.1.2"><p id="afa5ef86b0da84d6db423e3026452c36e"><a name="afa5ef86b0da84d6db423e3026452c36e"></a><a name="afa5ef86b0da84d6db423e3026452c36e"></a>Mandatory</p>
153        </th>
154        <th class="cellrowborder" valign="top" width="15.21%" id="mcps1.1.5.1.3"><p id="a9af4eafce7f64e28b91d13840b0ebcbe"><a name="a9af4eafce7f64e28b91d13840b0ebcbe"></a><a name="a9af4eafce7f64e28b91d13840b0ebcbe"></a>Data Type</p>
155        </th>
156        <th class="cellrowborder" valign="top" width="61.39%" id="mcps1.1.5.1.4"><p id="abeeb3a23760d45939183b063ebd23980"><a name="abeeb3a23760d45939183b063ebd23980"></a><a name="abeeb3a23760d45939183b063ebd23980"></a>Description</p>
157        </th>
158        </tr>
159        </thead>
160        <tbody><tr id="r7e6639aad87e416ab86b866f8e41f99e"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a2e815fd48b364454993f15e71fe77098"><a name="a2e815fd48b364454993f15e71fe77098"></a><a name="a2e815fd48b364454993f15e71fe77098"></a>mod</p>
161        </td>
162        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="a69360b58343843629f44854149aedac6"><a name="a69360b58343843629f44854149aedac6"></a><a name="a69360b58343843629f44854149aedac6"></a>Yes</p>
163        </td>
164        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a73824d7214b945baa2e8ed3cfc8ec3d2"><a name="a73824d7214b945baa2e8ed3cfc8ec3d2"></a><a name="a73824d7214b945baa2e8ed3cfc8ec3d2"></a>uint8</p>
165        </td>
166        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="a306257d426c040ebb352413f0ad22730"><a name="a306257d426c040ebb352413f0ad22730"></a><a name="a306257d426c040ebb352413f0ad22730"></a>Module or service ID.</p>
167        <p id="ac6cda7a8fb154e08bb81c97c329c12e6"><a name="ac6cda7a8fb154e08bb81c97c329c12e6"></a><a name="ac6cda7a8fb154e08bb81c97c329c12e6"></a>IDs are planned and allocated in a unified manner. A maximum of 64 IDs are supported. Third-party applications use <strong id="en-us_topic_0000001051742157_b0632102212343"><a name="en-us_topic_0000001051742157_b0632102212343"></a><a name="en-us_topic_0000001051742157_b0632102212343"></a>HILOG_MODULE_APP</strong> as their module ID.</p>
168        </td>
169        </tr>
170        <tr id="r94a3462cd6a2429baabd1f1c2ec46868"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a1d00ea1c726040b4b018fb84f30ea0a7"><a name="a1d00ea1c726040b4b018fb84f30ea0a7"></a><a name="a1d00ea1c726040b4b018fb84f30ea0a7"></a>fmt</p>
171        </td>
172        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="a41bdb7eaba30400e876efbef6fd419ea"><a name="a41bdb7eaba30400e876efbef6fd419ea"></a><a name="a41bdb7eaba30400e876efbef6fd419ea"></a>Yes</p>
173        </td>
174        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a29306f4446424bc1878e6ec62d528725"><a name="a29306f4446424bc1878e6ec62d528725"></a><a name="a29306f4446424bc1878e6ec62d528725"></a>char *</p>
175        </td>
176        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="aa050915fc17e4308a596eac11126f7f1"><a name="aa050915fc17e4308a596eac11126f7f1"></a><a name="aa050915fc17e4308a596eac11126f7f1"></a>Format specifier for output.</p>
177        <p id="a0b8e453d8f79476f836d740bf321f248"><a name="a0b8e453d8f79476f836d740bf321f248"></a><a name="a0b8e453d8f79476f836d740bf321f248"></a>1. A maximum of six variable parameters are supported. <strong id="b820071113185"><a name="b820071113185"></a><a name="b820071113185"></a>%s</strong> is not supported.</p>
178        <p id="a965a11a4bc1d4051b6df1e6e7379b691"><a name="a965a11a4bc1d4051b6df1e6e7379b691"></a><a name="a965a11a4bc1d4051b6df1e6e7379b691"></a>2. The maximum length of a formatted log record is 128 bytes. If the maximum length is exceeded, new logs cannot be printed.</p>
179        </td>
180        </tr>
181        <tr id="r6332c90d65704e7e86f4d621a9fcfe74"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a518fca3b03cb4431bb83b3eaa9309eb1"><a name="a518fca3b03cb4431bb83b3eaa9309eb1"></a><a name="a518fca3b03cb4431bb83b3eaa9309eb1"></a>Variable parameters</p>
182        </td>
183        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="aa5fbcb8d1d8742a39ee76b96ef6d4d56"><a name="aa5fbcb8d1d8742a39ee76b96ef6d4d56"></a><a name="aa5fbcb8d1d8742a39ee76b96ef6d4d56"></a>No</p>
184        </td>
185        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a6f4d9ca5beaa4e8187e6b50d478af7eb"><a name="a6f4d9ca5beaa4e8187e6b50d478af7eb"></a><a name="a6f4d9ca5beaa4e8187e6b50d478af7eb"></a>int32</p>
186        </td>
187        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="a7ebc1ecb043044d08dba95031abc5700"><a name="a7ebc1ecb043044d08dba95031abc5700"></a><a name="a7ebc1ecb043044d08dba95031abc5700"></a>Variable parameters. Only numeric types are supported. A maximum of six variable parameters are allowed.</p>
188        </td>
189        </tr>
190        </tbody>
191        </table>
192
193
194
195## Small System<a name="s33e0a62bc1dd4a2a9578fc22bd023f11"></a>
196
197**Native C and C++ APIs**
198
199Available HiLog APIs are as follows:
200
201```
202HILOG_DEBUG(type, ...)
203HILOG_INFO(type, ...)
204HILOG_WARN(type, ...)
205HILOG_ERROR(type, ...)
206HILOG_FATAL(type, ...)
207```
208
209Usage guidelines:
210
2111. Define the log tag.
212
2132. Perform local debugging. \(The domain value  **0**  can be used.\)
214
2153. Include the header file using  **\#include <hilog/log.h\>**.
216
2174. Add the dependency library  **libhilog**  to  **BUILD.gn**.
218
219API rules:
220
2211. The format specifier is labeled public by default, for example,  **HILOGI\("Hello World\\n"\); \>\> Hello World**.
222
2232. The formatted parameter is labeled private by default, for example,  **HILOGI\("Age is %d\\n", 10\); \>\> Age is <private\>**.
224
2253. Parameters labeled  **%\{private\}**  are private data, for example,  **HILOGI\("Age is %\{private\}d\\n", 10\); \>\> Age is <private\>**.
226
2274. Parameters labeled  **%\{public\}**  are public data, for example,  **HILOGI\("Age is %\{public\}d\\n", 10\); \>\>Age is 10**.
228
229Parameter description
230
231<a name="t3027cfdb064a423d815607ebc0790c5b"></a>
232<table><thead align="left"><tr id="r7c745f75ae7c4caca52d02b8ea7d922f"><th class="cellrowborder" valign="top" width="25.94%" id="mcps1.1.3.1.1"><p id="ae90a5f6e584048898aca3c9e8b92546a"><a name="ae90a5f6e584048898aca3c9e8b92546a"></a><a name="ae90a5f6e584048898aca3c9e8b92546a"></a>Parameter</p>
233</th>
234<th class="cellrowborder" valign="top" width="74.06%" id="mcps1.1.3.1.2"><p id="add5f3970c65244a2af03fbbbb4e8dd9f"><a name="add5f3970c65244a2af03fbbbb4e8dd9f"></a><a name="add5f3970c65244a2af03fbbbb4e8dd9f"></a>Description</p>
235</th>
236</tr>
237</thead>
238<tbody><tr id="r2046ed95b2bf458e8ef3425b6c597174"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a1feb6efbb48547d28a8e71ee0a61242a"><a name="a1feb6efbb48547d28a8e71ee0a61242a"></a><a name="a1feb6efbb48547d28a8e71ee0a61242a"></a>domain</p>
239</td>
240<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a8027bbc4329d4d32a7a45b294531d213"><a name="a8027bbc4329d4d32a7a45b294531d213"></a><a name="a8027bbc4329d4d32a7a45b294531d213"></a>Domain ID</p>
241</td>
242</tr>
243<tr id="rdbcb919a55204f55b16c186c625c493f"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a716122a0fa304d089dcd248301a5b7e4"><a name="a716122a0fa304d089dcd248301a5b7e4"></a><a name="a716122a0fa304d089dcd248301a5b7e4"></a>tag</p>
244</td>
245<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a527cd7253b79449cadba49bae525d7e9"><a name="a527cd7253b79449cadba49bae525d7e9"></a><a name="a527cd7253b79449cadba49bae525d7e9"></a>Log tag</p>
246</td>
247</tr>
248<tr id="ree2e47f74c664e66930f773a88c5955d"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a3b7919fb6fe349cda481b7e49809c9b1"><a name="a3b7919fb6fe349cda481b7e49809c9b1"></a><a name="a3b7919fb6fe349cda481b7e49809c9b1"></a>isFmtPrivate</p>
249</td>
250<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="ae858f47965f442298e5200b9db805c2f"><a name="ae858f47965f442298e5200b9db805c2f"></a><a name="ae858f47965f442298e5200b9db805c2f"></a>Whether the format specifier is private (Value <strong id="b188181937113818"><a name="b188181937113818"></a><a name="b188181937113818"></a>yes</strong> means that the format specifier is private.)</p>
251</td>
252</tr>
253<tr id="r7c847c32fa1d42b98a6321aa03683f9b"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a5af240669e8649a1a979655a2c4fc904"><a name="a5af240669e8649a1a979655a2c4fc904"></a><a name="a5af240669e8649a1a979655a2c4fc904"></a>fmt</p>
254</td>
255<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a9a09fcea9ba54456bb9769dd5fccd8f2"><a name="a9a09fcea9ba54456bb9769dd5fccd8f2"></a><a name="a9a09fcea9ba54456bb9769dd5fccd8f2"></a>Format specifier</p>
256</td>
257</tr>
258<tr id="ra7a3bc01bac24a97b5296680ea5ec315"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a4158d666b3e84d1c95ae796afd9371a2"><a name="a4158d666b3e84d1c95ae796afd9371a2"></a><a name="a4158d666b3e84d1c95ae796afd9371a2"></a>args</p>
259</td>
260<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="ac27db004bb6b4e21aebe139c89347e11"><a name="ac27db004bb6b4e21aebe139c89347e11"></a><a name="ac27db004bb6b4e21aebe139c89347e11"></a>Parameters to be displayed using the format specifier</p>
261</td>
262</tr>
263</tbody>
264</table>
265
266**Viewing logs**
267
2681.  Go to the  **/storage/data/log/**  directory to view hilog logs generated during debugging.
269
2702.  Run the  **hilogcat**  command to view hilog logs in real time.
271
272
273**Log system architecture**
274
275![](figures/en-us_image_0000001078803238.png)
276
2771.  hilogtask: log task in the kernel
278    -   This is a task or thread of the Linux kernel. It is initialized during system startup.
279    -   When a module in the kernel calls the log API, the formatted log content is transferred to the task and stored in a ringbuffer.
280    -   When the log API is called in the user space, the formatted log content is written into the driver node by calling  **ioctl**. The driver node then sends the log content to hilogtask, and hilogtask stores the log content in the ringbuffer.
281
2822.  hilogcatd: storage for logs in user space
283    -   This is a user-space process. It periodically reads the log content from the ringbuffer and stores it in the log file.
284    -   Log files can be compressed in  **gzip**  format by using  **zlib**.
285    -   The size of a single file and the number of files can be configured during compilation.
286
2873.  hilogcat: command line tool for viewing logs
288
289    This tool reads the log content in the ringbuffer via the kernel driver API, and then outputs the content to  **stdout**.
290
2914.  ringbuffer: configurable buffer for logs
292    -   The ringbuffer size can be configured during compilation.
293
294
295## Repositories Involved<a name="s999c697ebde345449386ce8dc1df1db0"></a>
296
297[DFX subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md)
298
299**hiviewdfx\_hilog\_lite**
300
301[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README.md)
302
303[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README.md)
304

README_zh.md

1# Hilog\_lite组件介绍<a name="ZH-CN_TOPIC_0000001078674780"></a>
2
3-   [简介](#s9c9ad6e6d5494719ad0f6630a0a1add4)
4-   [目录](#s4edd47ec6791449aa2d6362fed84325e)
5-   [约束](#s7f347323ea45437ca31edae5c10f2991)
6-   [使用-轻量系统](#sd6e99f792bc942f9bb5aa92111be7aff)
7-   [使用-小型系统](#s33e0a62bc1dd4a2a9578fc22bd023f11)
8-   [涉及仓](#s999c697ebde345449386ce8dc1df1db0)
9
10## 简介<a name="s9c9ad6e6d5494719ad0f6630a0a1add4"></a>
11
12提供DFX子系统在轻量系统和小型系统的流水日志功能。
13
14## 目录<a name="s4edd47ec6791449aa2d6362fed84325e"></a>
15
16**表 1**  DFX子系统hilog\_lite组件代码目录结构
17
18<a name="ta443dcf0f0dd4e07834b95e031c9fb12"></a>
19<table><thead align="left"><tr id="ra41be074cf4949d284a843a90e781f33"><th class="cellrowborder" valign="top" width="30.34%" id="mcps1.2.3.1.1"><p id="a727aecc17b674751a9d5d7ebdd391310"><a name="a727aecc17b674751a9d5d7ebdd391310"></a><a name="a727aecc17b674751a9d5d7ebdd391310"></a>名称</p>
20</th>
21<th class="cellrowborder" valign="top" width="69.66%" id="mcps1.2.3.1.2"><p id="ad32d72628b854c53ae4b7c54edfc8afe"><a name="ad32d72628b854c53ae4b7c54edfc8afe"></a><a name="ad32d72628b854c53ae4b7c54edfc8afe"></a>描述</p>
22</th>
23</tr>
24</thead>
25<tbody><tr id="rc4c61aa63a33430fb82263e2bda83e02"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a08bb3cab9f18422bbebabac53be94111"><a name="a08bb3cab9f18422bbebabac53be94111"></a><a name="a08bb3cab9f18422bbebabac53be94111"></a>interfaces/native/kits/hilog</p>
26</td>
27<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a4603eff664a64d7e80db8d890957522c"><a name="a4603eff664a64d7e80db8d890957522c"></a><a name="a4603eff664a64d7e80db8d890957522c"></a>小型系统流水日志对外接口定义</p>
28</td>
29</tr>
30<tr id="rf932828a7faa477e894fc6ac1405c5c2"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="aa165ba46894b44e396163892a274c308"><a name="aa165ba46894b44e396163892a274c308"></a><a name="aa165ba46894b44e396163892a274c308"></a>interfaces/native/kits/hilog_lite</p>
31</td>
32<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="af97241f84b4649de924f32608d0298da"><a name="af97241f84b4649de924f32608d0298da"></a><a name="af97241f84b4649de924f32608d0298da"></a>轻量系统流水日志对外接口定义</p>
33</td>
34</tr>
35<tr id="r81c09daddf724dc088992dc6fb5caeae"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a915128b09aeb4e25b1f7aba042c42459"><a name="a915128b09aeb4e25b1f7aba042c42459"></a><a name="a915128b09aeb4e25b1f7aba042c42459"></a>services/hilogcat</p>
36</td>
37<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a7645a6df6f164244b3292347b1f7ad04"><a name="a7645a6df6f164244b3292347b1f7ad04"></a><a name="a7645a6df6f164244b3292347b1f7ad04"></a>小型系统流水日志相关服务和命令</p>
38</td>
39</tr>
40<tr id="r4fa9d620df3c4e24bd1a94c79ccabcae"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a95c8bfabb4424e38a11d03a59162ae14"><a name="a95c8bfabb4424e38a11d03a59162ae14"></a><a name="a95c8bfabb4424e38a11d03a59162ae14"></a>services/apphilogcat</p>
41</td>
42<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a25c0853c8d0446839ea2b900856696cd"><a name="a25c0853c8d0446839ea2b900856696cd"></a><a name="a25c0853c8d0446839ea2b900856696cd"></a>小型系统流水日志落盘服务</p>
43</td>
44</tr>
45<tr id="r0a82ab924ac24725bcb24cf3fa523010"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="aba63f8bc7c0a469f94e6f8d177b5c91c"><a name="aba63f8bc7c0a469f94e6f8d177b5c91c"></a><a name="aba63f8bc7c0a469f94e6f8d177b5c91c"></a>command</p>
46</td>
47<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a1f274cd4df2949589ebe8a29c4e9a241"><a name="a1f274cd4df2949589ebe8a29c4e9a241"></a><a name="a1f274cd4df2949589ebe8a29c4e9a241"></a>轻量系统日志查询命令</p>
48</td>
49</tr>
50<tr id="rb359a73bb38e47c8952cf3a809b7d38d"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"><a name="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"></a><a name="a3a7a4fbfa61e45a5ba3bc4c4af4d82c2"></a>frameworks/featured</p>
51</td>
52<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="a307bdb53cf7545d4bd663fb62dd0ca38"><a name="a307bdb53cf7545d4bd663fb62dd0ca38"></a><a name="a307bdb53cf7545d4bd663fb62dd0ca38"></a>小型系统流水日志接口实现</p>
53</td>
54</tr>
55<tr id="rbb7fc424f05a4df181595f633455e8a8"><td class="cellrowborder" valign="top" width="30.34%" headers="mcps1.2.3.1.1 "><p id="a32392112d5b04f7e8baceca6353b9ecf"><a name="a32392112d5b04f7e8baceca6353b9ecf"></a><a name="a32392112d5b04f7e8baceca6353b9ecf"></a>frameworks/mini</p>
56</td>
57<td class="cellrowborder" valign="top" width="69.66%" headers="mcps1.2.3.1.2 "><p id="af1f91dea1e6b46dd983e659f936f22a7"><a name="af1f91dea1e6b46dd983e659f936f22a7"></a><a name="af1f91dea1e6b46dd983e659f936f22a7"></a>轻量系统流水日志接口实现</p>
58</td>
59</tr>
60</tbody>
61</table>
62
63## 约束<a name="s7f347323ea45437ca31edae5c10f2991"></a>
64
65轻量系统整体代码使用标准C开发。
66
67## 使用-轻量系统<a name="sd6e99f792bc942f9bb5aa92111be7aff"></a>
68
69-   **以下以A模块为例说明如何添加模块并进行日志打印。**
70    1.  **第一步添加模块ID**
71
72        在“base/hiviewdfx/hilog\_lite/interfaces/native/kits/hilog\_lite/hiview\_log.h“中添加HILOG\_MODULE\_A定义。
73
74        ```
75        typedef enum {
76            /** DFX */
77            HILOG_MODULE_HIVIEW = 0,
78            /** System Module A */
79            HILOG_MODULE_A,
80            /** Maximum number of modules */
81            HILOG_MODULE_MAX
82        } HiLogModuleType;
83        ```
84
85
86    1.  **第二步模块注册**
87
88        在A模块的初始化流程中添加如下代码,注册模块到日志框架中:
89
90        ```
91        HiLogRegisterModule(HILOG_MODULE_A, "A");
92        ```
93
94
95    1.  **第三步日志打印**
96
97        在需要打印日志的.c文件中 \#include "log.h",调用如下接口:
98
99        HILOG\_INFO\(HILOG\_MODULE\_A,“log test: %d”, 88\);
100
101        接口参数说明:
102
103        <a name="tb0e7329d09184f109c0cae274325b2f1"></a>
104        <table><thead align="left"><tr id="r74cdd06495cb4915ad894e023deff4b2"><th class="cellrowborder" valign="top" width="11.57%" id="mcps1.1.5.1.1"><p id="a8cfadf9da95144fd8a9eb9dbd1362b89"><a name="a8cfadf9da95144fd8a9eb9dbd1362b89"></a><a name="a8cfadf9da95144fd8a9eb9dbd1362b89"></a>参数名</p>
105        </th>
106        <th class="cellrowborder" valign="top" width="11.83%" id="mcps1.1.5.1.2"><p id="afa5ef86b0da84d6db423e3026452c36e"><a name="afa5ef86b0da84d6db423e3026452c36e"></a><a name="afa5ef86b0da84d6db423e3026452c36e"></a>是否必填</p>
107        </th>
108        <th class="cellrowborder" valign="top" width="15.21%" id="mcps1.1.5.1.3"><p id="a9af4eafce7f64e28b91d13840b0ebcbe"><a name="a9af4eafce7f64e28b91d13840b0ebcbe"></a><a name="a9af4eafce7f64e28b91d13840b0ebcbe"></a>参数类型</p>
109        </th>
110        <th class="cellrowborder" valign="top" width="61.39%" id="mcps1.1.5.1.4"><p id="abeeb3a23760d45939183b063ebd23980"><a name="abeeb3a23760d45939183b063ebd23980"></a><a name="abeeb3a23760d45939183b063ebd23980"></a>参数说明</p>
111        </th>
112        </tr>
113        </thead>
114        <tbody><tr id="r7e6639aad87e416ab86b866f8e41f99e"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a2e815fd48b364454993f15e71fe77098"><a name="a2e815fd48b364454993f15e71fe77098"></a><a name="a2e815fd48b364454993f15e71fe77098"></a>mod</p>
115        </td>
116        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="a69360b58343843629f44854149aedac6"><a name="a69360b58343843629f44854149aedac6"></a><a name="a69360b58343843629f44854149aedac6"></a>是</p>
117        </td>
118        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a73824d7214b945baa2e8ed3cfc8ec3d2"><a name="a73824d7214b945baa2e8ed3cfc8ec3d2"></a><a name="a73824d7214b945baa2e8ed3cfc8ec3d2"></a>uint8</p>
119        </td>
120        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="a306257d426c040ebb352413f0ad22730"><a name="a306257d426c040ebb352413f0ad22730"></a><a name="a306257d426c040ebb352413f0ad22730"></a>模块\服务的ID。</p>
121        <p id="ac6cda7a8fb154e08bb81c97c329c12e6"><a name="ac6cda7a8fb154e08bb81c97c329c12e6"></a><a name="ac6cda7a8fb154e08bb81c97c329c12e6"></a>统一规划分配,最大支持64个,其中第三方APP统一使用HILOG_MODULE_APP作为模块ID。</p>
122        </td>
123        </tr>
124        <tr id="r94a3462cd6a2429baabd1f1c2ec46868"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a1d00ea1c726040b4b018fb84f30ea0a7"><a name="a1d00ea1c726040b4b018fb84f30ea0a7"></a><a name="a1d00ea1c726040b4b018fb84f30ea0a7"></a>fmt</p>
125        </td>
126        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="a41bdb7eaba30400e876efbef6fd419ea"><a name="a41bdb7eaba30400e876efbef6fd419ea"></a><a name="a41bdb7eaba30400e876efbef6fd419ea"></a>是</p>
127        </td>
128        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a29306f4446424bc1878e6ec62d528725"><a name="a29306f4446424bc1878e6ec62d528725"></a><a name="a29306f4446424bc1878e6ec62d528725"></a>char *</p>
129        </td>
130        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="aa050915fc17e4308a596eac11126f7f1"><a name="aa050915fc17e4308a596eac11126f7f1"></a><a name="aa050915fc17e4308a596eac11126f7f1"></a>格式化输出字符串。</p>
131        <p id="a0b8e453d8f79476f836d740bf321f248"><a name="a0b8e453d8f79476f836d740bf321f248"></a><a name="a0b8e453d8f79476f836d740bf321f248"></a>1、  最大支持6个可变参数,不支持%s。</p>
132        <p id="a965a11a4bc1d4051b6df1e6e7379b691"><a name="a965a11a4bc1d4051b6df1e6e7379b691"></a><a name="a965a11a4bc1d4051b6df1e6e7379b691"></a>2、  格式化后的单条日志最大长度128字节,超过将无法打印。</p>
133        </td>
134        </tr>
135        <tr id="r6332c90d65704e7e86f4d621a9fcfe74"><td class="cellrowborder" valign="top" width="11.57%" headers="mcps1.1.5.1.1 "><p id="a518fca3b03cb4431bb83b3eaa9309eb1"><a name="a518fca3b03cb4431bb83b3eaa9309eb1"></a><a name="a518fca3b03cb4431bb83b3eaa9309eb1"></a>可变参</p>
136        </td>
137        <td class="cellrowborder" valign="top" width="11.83%" headers="mcps1.1.5.1.2 "><p id="aa5fbcb8d1d8742a39ee76b96ef6d4d56"><a name="aa5fbcb8d1d8742a39ee76b96ef6d4d56"></a><a name="aa5fbcb8d1d8742a39ee76b96ef6d4d56"></a>否</p>
138        </td>
139        <td class="cellrowborder" valign="top" width="15.21%" headers="mcps1.1.5.1.3 "><p id="a6f4d9ca5beaa4e8187e6b50d478af7eb"><a name="a6f4d9ca5beaa4e8187e6b50d478af7eb"></a><a name="a6f4d9ca5beaa4e8187e6b50d478af7eb"></a>int32</p>
140        </td>
141        <td class="cellrowborder" valign="top" width="61.39%" headers="mcps1.1.5.1.4 "><p id="a7ebc1ecb043044d08dba95031abc5700"><a name="a7ebc1ecb043044d08dba95031abc5700"></a><a name="a7ebc1ecb043044d08dba95031abc5700"></a>仅支持数字类型,最大支持6个变参。</p>
142        </td>
143        </tr>
144        </tbody>
145        </table>
146
147
148
149## 使用-小型系统<a name="s33e0a62bc1dd4a2a9578fc22bd023f11"></a>
150
151**Native C/C++接口**
152
153hilog  可用API
154
155```
156HILOG_DEBUG(type, ...)
157HILOG_INFO(type, ...)
158HILOG_WARN(type, ...)
159HILOG_ERROR(type, ...)
160HILOG_FATAL(type, ...)
161```
162
163使用介绍
164
1651. 首先需要定义TAG。
166
1672. 本地调试,可以临时使用domain数值 0。
168
1693. 包含头文件:\#include <hilog/log.h\>
170
1714. 在BUILD.gn中添加依赖库 libhilog。
172
173接口规则介绍:
174
1751. 格式化字符串默认是非隐私 HILOGI\("Hello World\\n"\); \>\> Hello World
176
1772. 格式化参数默认是隐私 HILOGI\("Age is %d\\n", 10\); \>\> Age is <private\>
178
1793. %\{private\}标识的参数是隐私 HILOGI\("Age is %\{private\}d\\n", 10\); \>\> Age is <private\>
180
1814. %\{public\}标识的参数是非隐私 HILOGI\("Age is %\{public\}d\\n", 10\); \>\>Age is 10
182
183接口参数介绍
184
185<a name="t3027cfdb064a423d815607ebc0790c5b"></a>
186<table><thead align="left"><tr id="r7c745f75ae7c4caca52d02b8ea7d922f"><th class="cellrowborder" valign="top" width="25.94%" id="mcps1.1.3.1.1"><p id="ae90a5f6e584048898aca3c9e8b92546a"><a name="ae90a5f6e584048898aca3c9e8b92546a"></a><a name="ae90a5f6e584048898aca3c9e8b92546a"></a>参数名字</p>
187</th>
188<th class="cellrowborder" valign="top" width="74.06%" id="mcps1.1.3.1.2"><p id="add5f3970c65244a2af03fbbbb4e8dd9f"><a name="add5f3970c65244a2af03fbbbb4e8dd9f"></a><a name="add5f3970c65244a2af03fbbbb4e8dd9f"></a>参数含义</p>
189</th>
190</tr>
191</thead>
192<tbody><tr id="r2046ed95b2bf458e8ef3425b6c597174"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a1feb6efbb48547d28a8e71ee0a61242a"><a name="a1feb6efbb48547d28a8e71ee0a61242a"></a><a name="a1feb6efbb48547d28a8e71ee0a61242a"></a>domain</p>
193</td>
194<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a8027bbc4329d4d32a7a45b294531d213"><a name="a8027bbc4329d4d32a7a45b294531d213"></a><a name="a8027bbc4329d4d32a7a45b294531d213"></a>领域标识ID</p>
195</td>
196</tr>
197<tr id="rdbcb919a55204f55b16c186c625c493f"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a716122a0fa304d089dcd248301a5b7e4"><a name="a716122a0fa304d089dcd248301a5b7e4"></a><a name="a716122a0fa304d089dcd248301a5b7e4"></a>tag</p>
198</td>
199<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a527cd7253b79449cadba49bae525d7e9"><a name="a527cd7253b79449cadba49bae525d7e9"></a><a name="a527cd7253b79449cadba49bae525d7e9"></a>日志tag</p>
200</td>
201</tr>
202<tr id="ree2e47f74c664e66930f773a88c5955d"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a3b7919fb6fe349cda481b7e49809c9b1"><a name="a3b7919fb6fe349cda481b7e49809c9b1"></a><a name="a3b7919fb6fe349cda481b7e49809c9b1"></a>isFmtPrivate</p>
203</td>
204<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="ae858f47965f442298e5200b9db805c2f"><a name="ae858f47965f442298e5200b9db805c2f"></a><a name="ae858f47965f442298e5200b9db805c2f"></a>标识格式化字符串fmt是否是隐私,是yes时fmt会被认为是隐私</p>
205</td>
206</tr>
207<tr id="r7c847c32fa1d42b98a6321aa03683f9b"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a5af240669e8649a1a979655a2c4fc904"><a name="a5af240669e8649a1a979655a2c4fc904"></a><a name="a5af240669e8649a1a979655a2c4fc904"></a>fmt</p>
208</td>
209<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="a9a09fcea9ba54456bb9769dd5fccd8f2"><a name="a9a09fcea9ba54456bb9769dd5fccd8f2"></a><a name="a9a09fcea9ba54456bb9769dd5fccd8f2"></a>格式化字符串</p>
210</td>
211</tr>
212<tr id="ra7a3bc01bac24a97b5296680ea5ec315"><td class="cellrowborder" valign="top" width="25.94%" headers="mcps1.1.3.1.1 "><p id="a4158d666b3e84d1c95ae796afd9371a2"><a name="a4158d666b3e84d1c95ae796afd9371a2"></a><a name="a4158d666b3e84d1c95ae796afd9371a2"></a>args</p>
213</td>
214<td class="cellrowborder" valign="top" width="74.06%" headers="mcps1.1.3.1.2 "><p id="ac27db004bb6b4e21aebe139c89347e11"><a name="ac27db004bb6b4e21aebe139c89347e11"></a><a name="ac27db004bb6b4e21aebe139c89347e11"></a>格式化字符串参数</p>
215</td>
216</tr>
217</tbody>
218</table>
219
220**日志查看**
221
2221.  debug版本hilog日志会保存到/storage/data/log/目录下面。
223
2242.  可以执行hilogcat实时查看hilog日志。
225
226
227**日志系统架构**
228
229![](figures/zh-cn_image_0000001078803238.png)
230
2311.  hilogtask流水日志的内核任务。
232    -   此功能是一个linux内核的任务或者线程,在系统启动时初始化。
233    -   当内核中一个模块调用它的日志接口,将格式化好的日志内容传输给改任务,并将其存储在一个环形缓冲区中 。
234    -   当用户态调用日志接口,将格式化好的日志内容通过ioctl调用写入驱动节点,驱动节点再将日志内容发送到hilogtask,hilogtask将日志内容存储到环形缓冲区中。
235
2362.  hilogcatd用户态日志存储服务。
237    -   这是一个用户态的进程,负责定时将内核的ringbuffer读取出来,存储到日志文件中。
238    -   日志文件输出支持gzip压缩,使用zlib
239    -   存储文件的单个文件大小,文件个数可在编译时配置。
240
2413.  hilogcat日志查看命令行工具。
242
243    从内核驱动接口读取ringbuffer内容,输出到标准输出。
244
2454.  支持日志缓冲区可配置。
246    -   编译时可以配置日志缓冲区的大小。
247
248
249## 涉及仓<a name="s999c697ebde345449386ce8dc1df1db0"></a>
250
251[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
252
253**hiviewdfx\_hilog\_lite**
254
255[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README_zh.md)
256
257[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README_zh.md)
258