• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #ifndef TEE_HILOG_LOCK_H
14 #define TEE_HILOG_LOCK_H
15 
16 #include <stdio.h>
17 #include "log.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #ifdef DEF_ENG
24 #define TEE_LOG_MASK    0
25 #else
26 #define TEE_LOG_MASK    2
27 #endif
28 
29 #define LOG_TAG_TEEC "tee_client"
30 
31 #define TAG_VERBOSE "[VERBOSE]"
32 #define TAG_DEBUG   "[DEBUG]"
33 #define TAG_INFO    "[INFO]"
34 #define TAG_WARN    "[WARN]"
35 #define TAG_ERROR   "[ERROR]"
36 
37 typedef enum {
38     LOG_LEVEL_ERROR  = 0,
39     LOG_LEVEL_WARN   = 1,
40     LOG_LEVEL_INFO   = 2,
41     LOG_LEVEL_DEBUG  = 3,
42     LOG_LEVEL_VERBO  = 4,
43 } LOG_LEVEL;
44 
45 #define tlogv(fmt, args...) \
46     do { \
47         if (TEE_LOG_MASK == 0) \
48             HILOG_DEBUG(HILOG_MODULE_SEC, "[%s]%s " fmt, LOG_TAG_TEEC, TAG_VERBOSE, ##args); \
49     } while (0)
50 
51 #define tlogd(fmt, args...) \
52     do { \
53         if (TEE_LOG_MASK <= 1) \
54             HILOG_DEBUG(HILOG_MODULE_SEC, "[%s]%s " fmt, LOG_TAG_TEEC, TAG_DEBUG, ##args); \
55     } while (0)
56 
57 #define tlogi(fmt, args...) \
58     do { \
59         if (TEE_LOG_MASK <= 2) \
60             HILOG_INFO(HILOG_MODULE_SEC, "[%s]%s " fmt, LOG_TAG_TEEC, TAG_INFO, ##args); \
61     } while (0)
62 
63 #define tlogw(fmt, args...) \
64     do { \
65         if (TEE_LOG_MASK <= 3) \
66             HILOG_WARN(HILOG_MODULE_SEC, "[%s]%s " fmt, LOG_TAG_TEEC, TAG_WARN, ##args); \
67     } while (0)
68 
69 #define tloge(fmt, args...) \
70     do { \
71         if (TEE_LOG_MASK <= 4) \
72             HILOG_ERROR(HILOG_MODULE_SEC, "[%s]%s " fmt, LOG_TAG_TEEC, TAG_ERROR, ##args); \
73     } while (0)
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif
80