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 <cinttypes> 20 21 #include "hilog/log.h" 22 #include "hisysevent.h" 23 #include "hitrace_meter.h" 24 25 #undef LOG_DOMAIN 26 #undef LOG_TAG 27 #define LOG_DOMAIN 0xD002B02 28 #define LOG_TAG "CAMERA_DPS" 29 #define MAX_STRING_SIZE 256 30 31 #ifndef IS_RELEASE_VERSION 32 #define DECORATOR_HILOG(op, fmt, args...) \ 33 do { \ 34 op(LOG_CORE, "{%{public}s()-%{public}s:%{public}d} " fmt, __FUNCTION__, __FILE_NAME__, __LINE__, ##args); \ 35 } while (0) 36 #else 37 #define DECORATOR_HILOG(op, fmt, args...) \ 38 do { \ 39 op(LOG_CORE, "{%{public}s():%{public}d} " fmt, __FUNCTION__, __LINE__, ##args); \ 40 } while (0) 41 #endif 42 43 #define DP_DEBUG_LOG(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__) 44 #define DP_ERR_LOG(fmt, ...) DECORATOR_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__) 45 #define DP_WARNING_LOG(fmt, ...) DECORATOR_HILOG(HILOG_WARN, fmt, ##__VA_ARGS__) 46 #define DP_INFO_LOG(fmt, ...) DECORATOR_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__) 47 #define DP_FATAL_LOG(fmt, ...) DECORATOR_HILOG(HILOG_FATAL, fmt, ##__VA_ARGS__) 48 #define CAMERA_DP_SYNC_TRACE HITRACE_METER_NAME(HITRACE_TAG_ZCAMERA, __PRETTY_FUNCTION__) 49 50 #define DP_OK 0 51 #define DP_ERR (1) 52 #define DP_INVALID_PARAM (2) 53 #define DP_INIT_FAIL (3) 54 #define DP_PERMISSION_DENIED (4) 55 #define DP_MEM_MAP_FAILED (5) 56 #define DP_INSUFFICIENT_RESOURCES (6) 57 #define DP_NULL_POINTER (7) 58 #define DP_SEND_COMMAND_FAILED (8) 59 #define DP_NOT_AVAILABLE (9) 60 61 #define DP_CHECK_ERROR_RETURN_RET_LOG(cond, ret, fmt, ...) \ 62 do { \ 63 if (cond) { \ 64 DP_ERR_LOG(fmt, ##__VA_ARGS__); \ 65 return ret; \ 66 } \ 67 } while (0) 68 69 #define DP_CHECK_ERROR_RETURN_LOG(cond, fmt, ...) \ 70 do { \ 71 if (cond) { \ 72 DP_ERR_LOG(fmt, ##__VA_ARGS__); \ 73 return; \ 74 } \ 75 } while (0) 76 77 #define DP_CHECK_ERROR_PRINT_LOG(cond, fmt, ...) \ 78 do { \ 79 if (cond) { \ 80 DP_ERR_LOG(fmt, ##__VA_ARGS__); \ 81 } \ 82 } while (0) 83 84 #define DP_CHECK_ERROR_BREAK_LOG(cond, fmt, ...) \ 85 if (1) { \ 86 if (cond) { \ 87 DP_ERR_LOG(fmt, ##__VA_ARGS__); \ 88 break; \ 89 } \ 90 } else void (0) 91 92 #define DP_CHECK_RETURN_RET(cond, ret) \ 93 do { \ 94 if (cond) { \ 95 return ret; \ 96 } \ 97 } while (0) 98 99 #define DP_CHECK_EXECUTE(cond, cmd) \ 100 do { \ 101 if (cond) { \ 102 cmd; \ 103 } \ 104 } while (0) 105 106 #define DP_CHECK_RETURN(cond) \ 107 do { \ 108 if (cond) { \ 109 return; \ 110 } \ 111 } while (0) 112 113 #define DP_CHECK_RETURN_RET_LOG(cond, ret, fmt, ...) \ 114 do { \ 115 if (cond) { \ 116 DP_INFO_LOG(fmt, ##__VA_ARGS__); \ 117 return ret; \ 118 } \ 119 } while (0) 120 121 #define DP_CHECK_RETURN_LOG(cond, fmt, ...) \ 122 do { \ 123 if (cond) { \ 124 DP_INFO_LOG(fmt, ##__VA_ARGS__); \ 125 return; \ 126 } \ 127 } while (0) 128 129 #define DP_CHECK_BREAK_LOG(cond, fmt, ...) \ 130 if (1) { \ 131 if (cond) { \ 132 DP_INFO_LOG(fmt, ##__VA_ARGS__); \ 133 break; \ 134 } \ 135 } else void (0) 136 137 #define DP_CHECK_CONTINUE_LOG(cond, fmt, ...) \ 138 if (1) { \ 139 if (cond) { \ 140 DP_INFO_LOG(fmt, ##__VA_ARGS__); \ 141 continue; \ 142 } \ 143 } else void (0) 144 #endif // OHOS_CAMERA_DPS_LOG_H