| boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.|
| boolean | Returns **true** if the local digit switch is turned on; returns **false** otherwise.|
**Error codes**
**Error codes**
...
@@ -707,7 +707,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
...
@@ -707,7 +707,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
isRTL(locale: string): boolean
isRTL(locale: string): boolean
Checks whether the localized script for the specified language is displayed from right to left.
| locale | string | Yes | Valid locale value, for example, **zh-Hans-CN**. |
| locale | string | Yes | Valid locale value, for example, **zh-Hans-CN**. |
| type | string | No | Valid calendar type. Currently, the valid types are as follows: **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic\_civil**, **islamic\_tbla**, **islamic\_umalqura**, **japanese**, and **persian**. If this parameter is left unspecified, the default calendar type of the specified locale is used.|
| type | string | No | Valid calendar type. Currently, the valid types are as follows: **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic\_civil**, **islamic\_tbla**, **islamic\_umalqura**, **japanese**, and **persian**. The default value is the default calendar type of the locale.|
**Return value**
**Return value**
...
@@ -818,9 +818,9 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
...
@@ -818,9 +818,9 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
| year | number | Yes | Year to set. |
| year | number | Yes | Year to set. |
| month | number | Yes | Month to set. |
| month | number | Yes | Month to set. |
| date | number | Yes | Day to set. |
| date | number | Yes | Day to set. |
| hour | number | No | Hour to set.|
| hour | number | No | Hour to set. The default value is the system hour.|
| minute | number | No | Minute to set.|
| minute | number | No | Minute to set. The default value is the system minute.|
| second | number | No | Second to set. |
| second | number | No | Second to set. The default value is the system second.|
**Example**
**Example**
```js
```js
...
@@ -990,7 +990,7 @@ Obtains the value of the specified field in the **Calendar** object.
...
@@ -990,7 +990,7 @@ Obtains the value of the specified field in the **Calendar** object.
getDisplayName(locale: string): string
getDisplayName(locale: string): string
Obtains the **Calendar** object name displayed for the specified locale.
Obtains the displayed name of the **Calendar** object for the specified locale.
| locale | string | Yes | Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.|
| locale | string | Yes | Locale for the displayed name of the **Calendar** object. For example, displayed name of **buddhist** is **Buddhist Calendar** when the locale is set to **en-US**.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ------ | ------------------- |
| ------ | ------------------- |
| string | **Calendar** object name displayed for the specified locale.|
| string | Displayed name of the **Calendar** object for the specified locale.|
**Example**
**Example**
```js
```js
...
@@ -1017,7 +1017,7 @@ Obtains the **Calendar** object name displayed for the specified locale.
...
@@ -1017,7 +1017,7 @@ Obtains the **Calendar** object name displayed for the specified locale.
isWeekend(date?: Date): boolean
isWeekend(date?: Date): boolean
Checks whether the specified date in this **Calendar** object is a weekend.
Checks whether a given date is a weekend in the calendar.
| date | Date | No | Specified date in this **Calendar** object. If the **date** parameter is not specified, the system checks whether the current date is a weekend.|
| date | Date | No | Specified date. If this parameter is left empty, the system checks whether the current date is a weekend. The default value is the system date.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ------- | ----------------------------------- |
| ------- | ----------------------------------- |
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
| boolean | Returns **true** if the specified date is a weekend; returns **false** otherwise.|
**Example**
**Example**
```js
```js
...
@@ -1059,7 +1059,7 @@ Creates a **PhoneNumberFormat** object.
...
@@ -1059,7 +1059,7 @@ Creates a **PhoneNumberFormat** object.
| country | string | Yes | Country or region to which the phone number to be formatted belongs.|
| country | string | Yes | Country or region to which the phone number to be formatted belongs.|
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. The default value is **NATIONAL**. |
**Example**
**Example**
```js
```js
...
@@ -1184,13 +1184,13 @@ Creates an **IndexUtil** object.
...
@@ -1184,13 +1184,13 @@ Creates an **IndexUtil** object.
| locale | string | No | A string containing locale information, including the language, optional script, and region.|
| locale | string | No | A string containing locale information, including the language, optional script, and region. The default value is the system locale.|
@@ -1400,7 +1400,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
...
@@ -1400,7 +1400,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
| Type | Description |
| Type | Description |
| ------ | ------------------ |
| ------ | ------------------ |
| number | Offset to the last text boundary of the processed text.|
| number | Offset to the last break point of the processed text.|
**Example**
**Example**
```js
```js
...
@@ -1414,7 +1414,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
...
@@ -1414,7 +1414,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
next(index?: number): number
next(index?: number): number
Moves the [BreakIterator](#breakiterator8) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#breakiterator8) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**.
Moves the **BreakIterator** object backward by the corresponding number of break points.
| index | number | No | Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.|
| index | number | No | Number of break points to be moved by the **BreakIterator** object. A positive value indicates that the break point is moved backward by the specified number of break points, and a negative value indicates the opposite. The default value is **1**.|
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
| number | Position of the **BreakIterator** object in the text after it is moved by the specified number of break points. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of break points.|
**Example**
**Example**
```js
```js
...
@@ -1444,7 +1444,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
...
@@ -1444,7 +1444,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
previous(): number
previous(): number
Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
Moves the **BreakIterator** object forward by one break point.
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
| number | Position of the **BreakIterator** object in the text after it is moved to the previous break point. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of break points.|
**Example**
**Example**
```js
```js
...
@@ -1468,7 +1468,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
...
@@ -1468,7 +1468,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
following(offset: number): number
following(offset: number): number
Moves the [BreakIterator](#breakiterator8) object to the text boundary after the position specified by the offset. Position of the [BreakIterator](#breakiterator8) object after it is moved to the text boundary after the position specified by the offset.
Moves the **BreakIterator** to the break point following the specified position.
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
| number | The value **-1** is returned if the break point to which the **BreakIterator** object is moved is outside of the processed text.|
**Example**
**Example**
```js
```js
...
@@ -1498,7 +1498,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
...
@@ -1498,7 +1498,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
isBoundary(offset: number): boolean
isBoundary(offset: number): boolean
Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#breakiterator8) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#breakiterator8) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following](#following8)(offset).
Checks whether the specified position of the text is a break point.
@@ -1506,13 +1506,13 @@ Checks whether the position specified by the offset is a text boundary. If **tru
...
@@ -1506,13 +1506,13 @@ Checks whether the position specified by the offset is a text boundary. If **tru
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----------- |
| ------ | ------ | ---- | ----------- |
| offset | number | Yes | Position to check.|
| offset | number | Yes | Offset to the specified position of the text. The value **true** is returned if the position specified by **offset** is a break point, and the value **false** is returned otherwise. If **true** is returned, the **BreakIterator** object is moved to the position specified by **offset**. Otherwise, **following** is called.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ------- | ------------------------------- |
| ------- | ------------------------------- |
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
| boolean | Returns **true** if the position specified by the offset is a break point; returns **false** otherwise.|
**Example**
**Example**
```js
```js
...
@@ -1535,7 +1535,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
...
@@ -1535,7 +1535,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| ------ | ------ | ---- | ----- |
| zondID | string | No | Time zone ID.|
| zondID | string | No | Time zone ID. The default value is the system time zone.|
**Return value**
**Return value**
...
@@ -1577,7 +1577,7 @@ Obtains the ID of the specified **TimeZone** object.
...
@@ -1577,7 +1577,7 @@ Obtains the ID of the specified **TimeZone** object.
| locale | string | No | Locale ID. The default value is the system locale. |
| isDST | boolean | No | Whether to consider DST when obtaining the representation of the **TimeZone** object.|
| isDST | boolean | No | Whether DST is considered in the localized representation of the **TimeZone** object. The default value is **false**.|
**Return value**
**Return value**
...
@@ -1634,7 +1634,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
...
@@ -1634,7 +1634,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
| Type | Description |
| Type | Description |
| ------ | ----------------------- |
| ------ | ----------------------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point. The default value is the system time zone.|
**Example**
**Example**
```js
```js
...
@@ -1689,7 +1689,7 @@ Obtains the list of time zone city IDs supported by the system.
...
@@ -1689,7 +1689,7 @@ Obtains the list of time zone city IDs supported by the system.
| regions | Array<string> | Yes | List of countries/regions to be sorted.|
| regions | Array<string> | Yes | List of countries/regions to be sorted.|
| options | [SortOptions](#sortoptions10) | No | Country/region sorting option.|
| options | [SortOptions](#sortoptions10) | No | Country/region sorting option. The default value of **locale** is the system locale, the default value of **isUseLocalName** is **false**, and the default value of **isSuggestedFirst** is **true**.|
**Return value**
**Return value**
...
@@ -2320,25 +2320,72 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
...
@@ -2320,25 +2320,72 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| locale | string | No | System locale, for example, **zh-Hans-CN**. |
| locale | string | No | System locale, for example, **zh-Hans-CN**. The default value of **locale** is the system locale. |
| isUseLocalName | boolean | No | Whether to use the local name for sorting. |
| isUseLocalName | boolean | No | Whether to use the local name for sorting. If **getLanguageInfoArray** is called, the default value of **isUseLocalName** is **true**. If **getRegionInfoArray** is called, the default value of **isUseLocalName** is **false**. |
| isSuggestedFirst | boolean | No | Whether to move the recommended language or country/region to the top in the sorting result. |
| isSuggestedFirst | boolean | No | Whether to move the recommended language or country/region to the top in the sorting result. The default value of **isSuggestedFirst** is **true**. |
Adds a preferred language to the specified position on the preferred language list.
Adds a preferred language to the specified position on the preferred language list.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.addPreferredLanguage](#addpreferredlanguage9) instead.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.addPreferredLanguage](#addpreferredlanguage9).
Deletes a preferred language from the specified position on the preferred language list.
Deletes a preferred language from the specified position on the preferred language list.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.removePreferredLanguage](#removepreferredlanguage9) instead.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.removePreferredLanguage](#removepreferredlanguage9).
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getPreferredLanguageList](#getpreferredlanguagelist9) instead.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getPreferredLanguageList](#getpreferredlanguagelist9).
Obtains the first language in the preferred language list.
Obtains the first language in the preferred language list.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getFirstPreferredLanguage](#getfirstpreferredlanguage9) instead.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getFirstPreferredLanguage](#getfirstpreferredlanguage9).
For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level.
For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level.
\@syscap SystemCapability.HiviewDFX.HiLog
**Since:**
@syscap SystemCapability.HiviewDFX.HiLog
**Since**
8
8
## Summary
## Summary
### Files
### File
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>File to Include: <hilog/log.h> |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>**File to include**: <hilog/log.h><br>**Library**: libhitrace_ndk.z.so|
### Macros
### Macros
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file. |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file.|
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service. |
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service.|
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. |
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro.|
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. |
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs INFO logs. This is a function-like macro.|
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. |
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs WARN logs. This is a function-like macro.|
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. |
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro.|
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. |
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_\_VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro.|
| [OH_LOG_IsLoggable](#oh_log_isloggable)(unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. |
| [OH_LOG_IsLoggable](#oh_log_isloggable)(unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, tag, and level can be printed.|
## Description
## Macro Description
## Macro Description
...
@@ -56,193 +63,249 @@ For example, you can use logging functions to output logs of the specified log t
...
@@ -56,193 +63,249 @@ For example, you can use logging functions to output logs of the specified log t
### LOG_DOMAIN
### LOG_DOMAIN
```
```
#define LOG_DOMAIN 0
#define LOG_DOMAIN 0
```
```
**Description**<br>
**Description**
Defines the service domain for a log file.
Defines the service domain for a log file.
The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated.
The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated.
**Since**
8
### LOG_TAG
### LOG_TAG
```
```
#define LOG_TAG NULL
#define LOG_TAG NULL
```
```
**Description**<br>
**Description**
Defines a string constant used to identify the class, file, or service.
Defines a string constant used to identify the class, file, or service.
Outputs DEBUG logs. This is a function-like macro.
Outputs DEBUG logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
Outputs ERROR logs. This is a function-like macro.
Outputs ERROR logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
Outputs FATAL logs. This is a function-like macro.
Outputs FATAL logs. This is a function-like macro.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**See**
**See**
[OH_LOG_Print](#oh_log_print)
[OH_LOG_Print](#oh_log_print)
**Since**
8
## Enum Description
## Enum Description
### LogLevel
### LogLevel
```
```
enum LogLevel
enum LogLevel
```
```
**Description**<br>
**Description**
Enumerates log levels.
Enumerates log levels.
You are advised to select log levels based on their respective use cases:
You are advised to select log levels based on their respective use cases.
Log levels:
DEBUG: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
**DEBUG**: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
INFO: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
**INFO**: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
WARN: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
**WARN**: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
ERROR: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
**ERROR**: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
FATAL: indicates that a program or functionality is about to crash and the fault cannot be rectified.
**FATAL**: indicates that a program or functionality is about to crash and the fault cannot be rectified.
| Name | Description |
| Value| Description|
| -------- | -------- |
| -------- | -------- |
| LOG_DEBUG | DEBUG level to be used by OH_LOG_DEBUG |
| LOG_DEBUG | DEBUG level to be used by **OH_LOG_DEBUG**.|
| LOG_INFO | INFO level to be used by OH_LOG_INFO |
| LOG_INFO | INFO level to be used by **OH_LOG_INFO**.|
| LOG_WARN | WARN level to be used by OH_LOG_WARN |
| LOG_WARN | WARN level to be used by **OH_LOG_WARN**.|
| LOG_ERROR | ERROR level to be used by OH_LOG_ERROR |
| LOG_ERROR | ERROR level to be used by **OH_LOG_ERROR**.|
| LOG_FATAL | FATAL level to be used by OH_LOG_FATAL |
| LOG_FATAL | FATAL level to be used by **OH_LOG_FATAL**.|
**Since**
8
### LogType
### LogType
```
```
enum LogType
enum LogType
```
```
**Description**<br>
**Description**
Enumerates log types.
Enumerates log types.
Currently, only LOG_APP is available.
You can use this function to specify the type of output logs. Currently, only **LOG_APP** is available.
| Name | Description |
| Value| Description|
| -------- | -------- |
| -------- | -------- |
| LOG_APP | Application log |
| LOG_APP | Application log.|
**Since**
8
## Function Description
## Function Description
...
@@ -250,48 +313,60 @@ Currently, only LOG_APP is available.
...
@@ -250,48 +313,60 @@ Currently, only LOG_APP is available.
### OH_LOG_IsLoggable()
### OH_LOG_IsLoggable()
```
```
int bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level )
Checks whether logs of the specified service domain, log tag, and log level can be output.
**Parameters**
**Description**
Checks whether logs of the specified service domain, tag, and level can be printed.
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| domain | Indicates the service domain of logs. |
| domain | Service domain.|
| tag | Indicates the log tag. |
| tag | Log tag.|
| level | Indicates the log level. |
| level | Log level.|
**Returns**
**Returns**
Returns **true** if the specified logs can be output; returns **false** otherwise.
**true** if the specified logs can be output; **false** otherwise.
**Since**
8
### OH_LOG_Print()
### OH_LOG_Print()
```
```
int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... )
int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... )
```
```
**Description**<br>
**Description**
Outputs logs.
Outputs logs.
You can use this function to output logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.
You can use this function to output logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.
**Parameters**
**Parameters**
| Name | Description |
| Name| Description|
| -------- | -------- |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| type | Log type. The type for third-party applications is defined by **LOG_APP**.|
| level | Indicates the log level, which can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**. |
| level | Log level. The value can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**.|
| domain | Indicates the service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. |
| domain | Service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF.|
| tag | Indicates the log tag, which is a string used to identify the class, file, or service. |
| tag | Log tag, which is a string used to identify the class, file, or service.|
| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. |
| fmt | Format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter.|
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
| ... | Parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string.|
**Returns**
**Returns**
Returns **0** or a larger value if the operation is successful; returns a value smaller than **0** otherwise.
**0** or a larger value if the operation is successful; a value smaller than **0** otherwise.