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 AICPU_SHARDER_LOG_H
12 : #define AICPU_SHARDER_LOG_H
13 :
14 : #ifdef AICPU_SHARDER_UTST
15 :
16 : #include <stdio.h>
17 : #define AICPUE_LOGD(fmt, ...) \
18 : printf("[AICPU_SHARDER] %s:%s:%d:" fmt "\n", &__FUNCTION__[0], __FILE__, __LINE__, ##__VA_ARGS__)
19 : #define AICPUE_LOGI(fmt, ...) \
20 : printf("[AICPU_SHARDER] %s:%s:%d:" fmt "\n", &__FUNCTION__[0], __FILE__, __LINE__, ##__VA_ARGS__)
21 : #define AICPUE_LOGW(fmt, ...) \
22 : printf("[AICPU_SHARDER] %s:%s:%d:" fmt "\n", &__FUNCTION__[0], __FILE__, __LINE__, ##__VA_ARGS__)
23 : #define AICPUE_LOGE(fmt, ...) \
24 : printf("[AICPU_SHARDER] %s:%s:%d:" fmt "\n", &__FUNCTION__[0], __FILE__, __LINE__, ##__VA_ARGS__)
25 : #define AICPUE_RUN_LOGW(fmt, ...) \
26 : printf("[AICPU_SHARDER] %s:%s:%d:" fmt "\n", &__FUNCTION__[0], __FILE__, __LINE__, ##__VA_ARGS__)
27 :
28 : #else
29 : #include <unistd.h>
30 : #include <cstdint>
31 : #include <sys/syscall.h>
32 : #include "aicpu_sharder_weak_log.h"
33 : namespace aicpu {
34 133 : inline int64_t GetTid()
35 : {
36 133 : thread_local static const int64_t TID = syscall(__NR_gettid);
37 133 : return TID;
38 : }
39 : }
40 :
41 : #define AICPUE_LOGD(fmt, ...) \
42 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
43 : dlog_debug(static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, \
44 : &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
45 : }
46 : #define AICPUE_LOGI(fmt, ...) \
47 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
48 : dlog_info(static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, \
49 : &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
50 : }
51 : #define AICPUE_LOGW(fmt, ...) \
52 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
53 : dlog_warn(static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, \
54 : &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
55 : }
56 : #define AICPUE_LOGE(fmt, ...) \
57 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
58 : dlog_error(static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, \
59 : &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
60 : }
61 : #define AICPUE_LOGD(fmt, ...) \
62 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
63 : dlog_debug(static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, \
64 : &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
65 : }
66 :
67 : #define AICPUE_RUN_LOGW(fmt, ...) \
68 : if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) { \
69 : dlog_warn(static_cast<int32_t>(static_cast<uint32_t>(AICPU) | static_cast<uint32_t>(RUN_LOG_MASK)), \
70 : "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__); \
71 : }
72 :
73 : #endif // endif AICPU_SHARDER_UTST
74 :
75 : #endif
|