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, ...) do { \
23 : dlog_debug(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
24 : } while (0)
25 : #define IDE_LOGI(format, ...) do { \
26 : dlog_info(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
27 : } while (0)
28 :
29 : #define IDE_LOGW(format, ...) do { \
30 : dlog_warn(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
31 : } while (0)
32 :
33 : #define IDE_LOGE(format, ...) do { \
34 : dlog_error(Adx::ADX_MODULE_NAME, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
35 : } while (0)
36 :
37 34 : inline void AdxLogFlush()
38 : {
39 34 : DlogFlush();
40 34 : }
41 : #define IDE_RUN_LOGI(format, ...) do { \
42 : dlog_info(Adx::ADX_MODULE_NAME | RUN_LOG_MASK, "[tid:%d] " format "\n", mmGetTid(), ##__VA_ARGS__); \
43 : } while (0)
44 : #else
45 : #define IDE_LOGD(format, ...) do { \
46 : } while (0)
47 :
48 : #define IDE_LOGI(format, ...) do { \
49 : syslog(LOG_INFO, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
50 : } while (0)
51 :
52 : #define IDE_LOGW(format, ...) do { \
53 : syslog(LOG_WARNING, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
54 : } while (0)
55 :
56 : #define IDE_LOGE(format, ...) do { \
57 : syslog(LOG_ERR, "[tid:%ld] %s:%d: " format "\n", syscall(SYS_gettid), __FILE__, __LINE__, ##__VA_ARGS__); \
58 : } while (0)
59 :
60 : #define IDE_RUN_LOGI(format, ...) do { \
61 : } while (0)
62 :
63 : inline void AdxLogFlush()
64 : {
65 : }
66 :
67 : #endif
68 : }
69 : #endif // IDE_HDC_LOG_H
|