1d96309c9Sopenharmony_ci/*
2d96309c9Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
3d96309c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4d96309c9Sopenharmony_ci * you may not use this file except in compliance with the License.
5d96309c9Sopenharmony_ci * You may obtain a copy of the License at
6d96309c9Sopenharmony_ci *
7d96309c9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8d96309c9Sopenharmony_ci *
9d96309c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10d96309c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11d96309c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d96309c9Sopenharmony_ci * See the License for the specific language governing permissions and
13d96309c9Sopenharmony_ci * limitations under the License.
14d96309c9Sopenharmony_ci */
15d96309c9Sopenharmony_ci
16d96309c9Sopenharmony_ci#ifndef HIVIEWDFX_HILOG_CPP_H
17d96309c9Sopenharmony_ci#define HIVIEWDFX_HILOG_CPP_H
18d96309c9Sopenharmony_ci
19d96309c9Sopenharmony_ci#include "hiview_log.h"
20d96309c9Sopenharmony_ci
21d96309c9Sopenharmony_ci#ifdef __cplusplus
22d96309c9Sopenharmony_ci
23d96309c9Sopenharmony_cinamespace OHOS {
24d96309c9Sopenharmony_cinamespace HiviewDFX {
25d96309c9Sopenharmony_cistruct HiLogLabel {
26d96309c9Sopenharmony_ci    LogType type;
27d96309c9Sopenharmony_ci    unsigned int domain;
28d96309c9Sopenharmony_ci    const char *tag;
29d96309c9Sopenharmony_ci};
30d96309c9Sopenharmony_ci
31d96309c9Sopenharmony_ciclass HiLog final {
32d96309c9Sopenharmony_cipublic:
33d96309c9Sopenharmony_ci    /**
34d96309c9Sopenharmony_ci    * @brief Outputs debug logs.
35d96309c9Sopenharmony_ci    *
36d96309c9Sopenharmony_ci    * @param label Indicates the log label.
37d96309c9Sopenharmony_ci    * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the
38d96309c9Sopenharmony_ci    * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier
39d96309c9Sopenharmony_ci    * in each parameter. \n
40d96309c9Sopenharmony_ci    * @param... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
41d96309c9Sopenharmony_ci    * in the format string.
42d96309c9Sopenharmony_ci    * @return Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller than <b>0</b>
43d96309c9Sopenharmony_ci    * otherwise.
44d96309c9Sopenharmony_ci    * @since 1.1
45d96309c9Sopenharmony_ci    * @version 1.0
46d96309c9Sopenharmony_ci    */
47d96309c9Sopenharmony_ci    static int Debug(const HiLogLabel &label, const char *fmt, ...) __attribute__((__format__(printf, 2, 3)));
48d96309c9Sopenharmony_ci    /**
49d96309c9Sopenharmony_ci    * @brief Outputs informational logs.
50d96309c9Sopenharmony_ci    *
51d96309c9Sopenharmony_ci    * @param label Indicates the log label.
52d96309c9Sopenharmony_ci    * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the
53d96309c9Sopenharmony_ci    * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier
54d96309c9Sopenharmony_ci    * in each parameter. \n
55d96309c9Sopenharmony_ci    * @param... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
56d96309c9Sopenharmony_ci    * in the format string.
57d96309c9Sopenharmony_ci    * @return Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller than <b>0</b>
58d96309c9Sopenharmony_ci    * otherwise.
59d96309c9Sopenharmony_ci    * @since 1.1
60d96309c9Sopenharmony_ci    * @version 1.0
61d96309c9Sopenharmony_ci    */
62d96309c9Sopenharmony_ci    static int Info(const HiLogLabel &label, const char *fmt, ...) __attribute__((__format__(printf, 2, 3)));
63d96309c9Sopenharmony_ci    /**
64d96309c9Sopenharmony_ci    * @brief Outputs warning logs.
65d96309c9Sopenharmony_ci    *
66d96309c9Sopenharmony_ci    * @param label Indicates the log label.
67d96309c9Sopenharmony_ci    * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the
68d96309c9Sopenharmony_ci    * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier
69d96309c9Sopenharmony_ci    * in each parameter. \n
70d96309c9Sopenharmony_ci    * @param... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
71d96309c9Sopenharmony_ci    * in the format string.
72d96309c9Sopenharmony_ci    * @return Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller than <b>0</b>
73d96309c9Sopenharmony_ci    * otherwise.
74d96309c9Sopenharmony_ci    * @since 1.1
75d96309c9Sopenharmony_ci    * @version 1.0
76d96309c9Sopenharmony_ci    */
77d96309c9Sopenharmony_ci    static int Warn(const HiLogLabel &label, const char *fmt, ...) __attribute__((__format__(printf, 2, 3)));
78d96309c9Sopenharmony_ci    /**
79d96309c9Sopenharmony_ci    * @brief Outputs error logs.
80d96309c9Sopenharmony_ci    *
81d96309c9Sopenharmony_ci    * @param label Indicates the log label.
82d96309c9Sopenharmony_ci    * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the
83d96309c9Sopenharmony_ci    * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier
84d96309c9Sopenharmony_ci    * in each parameter. \n
85d96309c9Sopenharmony_ci    * @param... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
86d96309c9Sopenharmony_ci    * in the format string.
87d96309c9Sopenharmony_ci    * @return Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller than <b>0</b>
88d96309c9Sopenharmony_ci    * otherwise.
89d96309c9Sopenharmony_ci    * @since 1.1
90d96309c9Sopenharmony_ci    * @version 1.0
91d96309c9Sopenharmony_ci    */
92d96309c9Sopenharmony_ci    static int Error(const HiLogLabel &label, const char *fmt, ...) __attribute__((__format__(printf, 2, 3)));
93d96309c9Sopenharmony_ci    /**
94d96309c9Sopenharmony_ci    * @brief Outputs fatal logs.
95d96309c9Sopenharmony_ci    *
96d96309c9Sopenharmony_ci    * @param label Indicates the log label.
97d96309c9Sopenharmony_ci    * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the
98d96309c9Sopenharmony_ci    * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier
99d96309c9Sopenharmony_ci    * in each parameter. \n
100d96309c9Sopenharmony_ci    * @param... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers
101d96309c9Sopenharmony_ci    * in the format string.
102d96309c9Sopenharmony_ci    * @return Returns <b>0</b> or a larger value if the operation is successful; returns a value smaller than <b>0</b>
103d96309c9Sopenharmony_ci    * otherwise.
104d96309c9Sopenharmony_ci    * @since 1.1
105d96309c9Sopenharmony_ci    * @version 1.0
106d96309c9Sopenharmony_ci    */
107d96309c9Sopenharmony_ci    static int Fatal(const HiLogLabel &label, const char *fmt, ...) __attribute__((__format__(printf, 2, 3)));
108d96309c9Sopenharmony_ci};
109d96309c9Sopenharmony_ci} // namespace HiviewDFX
110d96309c9Sopenharmony_ci} // namespace OHOS
111d96309c9Sopenharmony_ci#endif // __cplusplus
112d96309c9Sopenharmony_ci
113d96309c9Sopenharmony_ci#endif // HIVIEWDFX_HILOG_CPP_H
114