• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_CAMERA_DPS_LOG_H
17 #define OHOS_CAMERA_DPS_LOG_H
18 
19 #include "hilog/log.h"
20 #include "hisysevent.h"
21 #include "hitrace_meter.h"
22 
23 #undef LOG_DOMAIN
24 #undef LOG_TAG
25 #define LOG_DOMAIN 0xD002B00
26 #define LOG_TAG "CAMERA_DPS"
27 #define MAX_STRING_SIZE 256
28 
29 #ifndef IS_RELEASE_VERSION
30 #define DECORATOR_HILOG(op, fmt, args...)                                                \
31     do {                                                                                 \
32         op(LOG_CORE, "{%{public}s()-%{public}s:%{public}d} " fmt, __FUNCTION__, __FILE_NAME__, __LINE__, ##args); \
33     } while (0)
34 #else
35 #define DECORATOR_HILOG(op, fmt, args...)                                                \
36     do {                                                                                 \
37         op(LOG_CORE, "{%{public}s():%{public}d} " fmt, __FUNCTION__, __LINE__, ##args); \
38     } while (0)
39 #endif
40 
41 #define DP_DEBUG_LOG(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__)
42 #define DP_ERR_LOG(fmt, ...) DECORATOR_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__)
43 #define DP_WARNING_LOG(fmt, ...) DECORATOR_HILOG(HILOG_WARN, fmt, ##__VA_ARGS__)
44 #define DP_INFO_LOG(fmt, ...) DECORATOR_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__)
45 #define DP_FATAL_LOG(fmt, ...) DECORATOR_HILOG(HILOG_FATAL, fmt, ##__VA_ARGS__)
46 #define CAMERA_DP_SYNC_TRACE HITRACE_METER_NAME(HITRACE_TAG_ZCAMERA, __PRETTY_FUNCTION__)
47 
48 #define DP_OK 0
49 #define DP_ERR (1)
50 #define DP_INVALID_PARAM (2)
51 #define DP_INIT_FAIL (3)
52 #define DP_PERMISSION_DENIED (4)
53 #define DP_MEM_MAP_FAILED (5)
54 #define DP_INSUFFICIENT_RESOURCES (6)
55 #define DP_NULL_POINTER (7)
56 #define DP_SEND_COMMAND_FAILED (8)
57 #define DP_NOT_AVAILABLE (9)
58 
59 #define DP_CHECK_ERROR_RETURN_RET_LOG(cond, ret, fmt, ...)  \
60     do {                                                    \
61         if (cond) {                                         \
62             DP_ERR_LOG(fmt, ##__VA_ARGS__);                 \
63             return ret;                                     \
64         }                                                   \
65     } while (0)
66 
67 #define DP_CHECK_ERROR_RETURN_LOG(cond, fmt, ...)           \
68     do {                                                    \
69         if (cond) {                                         \
70             DP_ERR_LOG(fmt, ##__VA_ARGS__);                 \
71             return;                                         \
72         }                                                   \
73     } while (0)
74 
75 #define DP_CHECK_ERROR_PRINT_LOG(cond, fmt, ...)            \
76     do {                                                    \
77         if (cond) {                                         \
78             DP_ERR_LOG(fmt, ##__VA_ARGS__);                 \
79         }                                                   \
80     } while (0)
81 
82 #define DP_CHECK_ERROR_BREAK_LOG(cond, fmt, ...)            \
83     if (1) {                                                \
84         if (cond) {                                         \
85             DP_ERR_LOG(fmt, ##__VA_ARGS__);                 \
86             break;                                          \
87         }                                                   \
88     } else void (0)
89 
90 #define DP_CHECK_RETURN_RET(cond, ret)                      \
91     do {                                                    \
92         if (cond) {                                         \
93             return ret;                                     \
94         }                                                   \
95     } while (0)
96 
97 #define DP_CHECK_EXECUTE(cond, cmd)                         \
98     do {                                                    \
99         if (cond) {                                         \
100             cmd;                                            \
101         }                                                   \
102     } while (0)
103 
104 #define DP_CHECK_RETURN(cond)                               \
105     do {                                                    \
106         if (cond) {                                         \
107             return;                                         \
108         }                                                   \
109     } while (0)
110 
111 #define DP_CHECK_RETURN_RET_LOG(cond, ret, fmt, ...)        \
112     do {                                                    \
113         if (cond) {                                         \
114             DP_INFO_LOG(fmt, ##__VA_ARGS__);                \
115             return ret;                                     \
116         }                                                   \
117     } while (0)
118 
119 #define DP_CHECK_RETURN_LOG(cond, fmt, ...)                 \
120     do {                                                    \
121         if (cond) {                                         \
122             DP_INFO_LOG(fmt, ##__VA_ARGS__);                \
123             return;                                         \
124         }                                                   \
125     } while (0)
126 
127 #define DP_CHECK_BREAK_LOG(cond, fmt, ...)                  \
128     if (1) {                                                \
129         if (cond) {                                         \
130             DP_INFO_LOG(fmt, ##__VA_ARGS__);                \
131             break;                                          \
132         }                                                   \
133     } else void (0)
134 
135 #define DP_CHECK_CONTINUE_LOG(cond, fmt, ...)               \
136     if (1) {                                                \
137         if (cond) {                                         \
138             DP_INFO_LOG(fmt, ##__VA_ARGS__);                \
139             continue;                                       \
140         }                                                   \
141     } else void (0)
142 #endif // OHOS_CAMERA_DPS_LOG_H