Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef IDE_HDC_LOG_H
12 : #define IDE_HDC_LOG_H
13 : #include <cstdint>
14 : #include <sys/syslog.h>
15 : #include "mmpa_api.h"
16 : #include "dlog_pub.h"
17 : namespace Adx {
18 : const int32_t ADX_MODULE_NAME = IDEDD;
19 : const int32_t MAX_ERRSTR_LEN = 128;
20 : #if defined(IDE_DAEMON_DEVICE) || defined(ADX_LIB) || defined(ADX_LIB_HOST)
21 :
22 : #define IDE_LOGD(format, ...) \
23 : do { \
24 : dlog_debug(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
25 : } while (0)
26 : #define IDE_LOGI(format, ...) \
27 : do { \
28 : dlog_info(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
29 : } while (0)
30 :
31 : #define IDE_LOGW(format, ...) \
32 : do { \
33 : dlog_warn(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
34 : } while (0)
35 :
36 : #define IDE_LOGE(format, ...) \
37 : do { \
38 : dlog_error(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
39 : } while (0)
40 :
41 34 : inline void AdxLogFlush() { DlogFlush(); }
42 : #define IDE_RUN_LOGI(format, ...) \
43 : do { \
44 : dlog_info(Adx::ADX_MODULE_NAME | RUN_LOG_MASK, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
45 : } while (0)
46 : #else
47 : #define IDE_LOGD(format, ...) \
48 : do { \
49 : } while (0)
50 :
51 : #define IDE_LOGI(format, ...) \
52 : do { \
53 : syslog(LOG_INFO, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
54 : } while (0)
55 :
56 : #define IDE_LOGW(format, ...) \
57 : do { \
58 : syslog(LOG_WARNING, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
59 : } while (0)
60 :
61 : #define IDE_LOGE(format, ...) \
62 : do { \
63 : syslog(LOG_ERR, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
64 : } while (0)
65 :
66 : #define IDE_RUN_LOGI(format, ...) \
67 : do { \
68 : } while (0)
69 :
70 : inline void AdxLogFlush() {}
71 :
72 : #endif
73 : } // namespace Adx
74 : #endif // IDE_HDC_LOG_H
|