• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-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 DEV_SLINFO_LOG_H
17 #define DEV_SLINFO_LOG_H
18 
19 #define LOG_PRINT_MAX_LEN 1024
20 
21 typedef enum {
22     LOG_LEVEL_DEBUG = 0,
23     LOG_LEVEL_INFO = 1,
24     LOG_LEVEL_WARN = 2,
25     LOG_LEVEL_ERROR = 3
26 } DataSlLogLevel;
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 void DataSlLogPrint(DataSlLogLevel level, const char *funName, const char *fmt, ...);
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #ifdef HILOG_ENABLE
39 
40 #include "hilog/log.h"
41 
42 #ifndef DATASL_LOG_DOMAIN
43 #define DATASL_LOG_DOMAIN 0xD002F04
44 #endif
45 
46 #define DATA_SEC_LOG_DEBUG(fmt, ...) (DataSlLogPrint(LOG_LEVEL_DEBUG, __FUNCTION__, fmt, ##__VA_ARGS__))
47 #define DATA_SEC_LOG_INFO(fmt, ...) (DataSlLogPrint(LOG_LEVEL_INFO, __FUNCTION__, fmt, ##__VA_ARGS__))
48 #define DATA_SEC_LOG_WARN(fmt, ...) (DataSlLogPrint(LOG_LEVEL_WARN, __FUNCTION__, fmt, ##__VA_ARGS__))
49 #define DATA_SEC_LOG_ERROR(fmt, ...) (DataSlLogPrint(LOG_LEVEL_ERROR, __FUNCTION__, fmt, ##__VA_ARGS__))
50 
51 #define DataSl_LOG_DEBUG(buf) HiLogPrint(LOG_CORE, LOG_DEBUG, DATASL_LOG_DOMAIN, "[DataSl]", "%{public}s", buf)
52 #define DataSl_LOG_INFO(buf) HiLogPrint(LOG_CORE, LOG_INFO, DATASL_LOG_DOMAIN, "[DataSl]", "%{public}s", buf)
53 #define DataSl_LOG_WARN(buf) HiLogPrint(LOG_CORE, LOG_WARN, DATASL_LOG_DOMAIN, "[DataSl]", "%{public}s", buf)
54 #define DataSl_LOG_ERROR(buf) HiLogPrint(LOG_CORE, LOG_ERROR, DATASL_LOG_DOMAIN, "[DataSl]", "%{public}s", buf)
55 
56 #else
57 
58 #include <stdio.h>
59 #include <stdlib.h>
60 
61 #define DATA_SEC_LOG_DEBUG(fmt, ...) printf("[DataSl][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
62 #define DATA_SEC_LOG_INFO(fmt, ...) printf("[DataSl][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
63 #define DATA_SEC_LOG_WARN(fmt, ...) printf("[DataSl][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
64 #define DATA_SEC_LOG_ERROR(fmt, ...) printf("[DataSl][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__)
65 
66 #endif
67 #endif