• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 __FFRT_LOG_API_H__
17 #define __FFRT_LOG_API_H__
18 
19 #include "log_base.h"
20 
21 #if (FFRT_LOG_LEVEL >= FFRT_LOG_DEBUG)
22 #define FFRT_LOGD(format, ...) FFRT_LOG(FFRT_LOG_DEBUG, format, ##__VA_ARGS__)
23 #else
24 #define FFRT_LOGD(format, ...)
25 #endif
26 
27 #if (FFRT_LOG_LEVEL >= FFRT_LOG_INFO)
28 #define FFRT_LOGI(format, ...) FFRT_LOG(FFRT_LOG_INFO, format, ##__VA_ARGS__)
29 #else
30 #define FFRT_LOGI(format, ...)
31 #endif
32 
33 #if (FFRT_LOG_LEVEL >= FFRT_LOG_WARN)
34 #define FFRT_LOGW(format, ...) FFRT_LOG(FFRT_LOG_WARN, format, ##__VA_ARGS__)
35 #else
36 #define FFRT_LOGW(format, ...)
37 #endif
38 
39 #define FFRT_LOGE(format, ...) FFRT_LOG(FFRT_LOG_ERROR, format, ##__VA_ARGS__)
40 
41 #define FFRT_COND_DO_ERR(cond, expr, format, ...) \
42     if (cond) {                                   \
43         FFRT_LOGE(format, ##__VA_ARGS__);         \
44         {                                         \
45             expr;                                 \
46         }                                         \
47     }
48 
49 // Do not use this Marco directly
50 #define COND_RETURN_(COND, ERRCODE, ...) \
51     if ((COND)) { \
52         FFRT_LOGE(__VA_ARGS__); \
53         return ERRCODE; \
54     }
55 
56 #define FFRT_COND_RETURN_ERROR(COND, ERRCODE, ...) \
57     COND_RETURN_((COND), ERRCODE, ##__VA_ARGS__)
58 
59 #define FFRT_COND_RETURN_VOID(COND, ...) \
60     if ((COND)) { \
61         FFRT_LOGE(__VA_ARGS__); \
62         return; \
63     }
64 
65 // Do not use this Marco directly
66 #define COND_GOTO_WITH_ERRCODE_(COND, LABEL, ERROR, ERRCODE, ...) \
67     if ((COND)) { \
68         FFRT_LOGE(__VA_ARGS__); \
69         ERROR = (ERRCODE); \
70         goto LABEL; \
71     }
72 
73 #define FFRT_COND_GOTO_ERROR(COND, LABEL, ERROR, ERRCODE, ...) \
74     COND_GOTO_WITH_ERRCODE_((COND), LABEL, ERROR, ERRCODE, ##__VA_ARGS__)
75 
76 #define FFRT_UNUSED(expr) \
77     do { \
78         (void)(expr); \
79     } while (0)
80 
81 #endif // __FFRT_LOG_API_H__
82