LCOV - code coverage report
Current view: top level - aicpu_sharder - aicpu_sharder_log.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 3 3
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 1 1

            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              : } // namespace aicpu
      40              : 
      41              : #define AICPUE_LOGD(fmt, ...)                                                                                    \
      42              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                               \
      43              :         dlog_debug(                                                                                              \
      44              :             static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), \
      45              :             ##__VA_ARGS__);                                                                                      \
      46              :     }
      47              : #define AICPUE_LOGI(fmt, ...)                                                                                    \
      48              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                               \
      49              :         dlog_info(                                                                                               \
      50              :             static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), \
      51              :             ##__VA_ARGS__);                                                                                      \
      52              :     }
      53              : #define AICPUE_LOGW(fmt, ...)                                                                                    \
      54              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                               \
      55              :         dlog_warn(                                                                                               \
      56              :             static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), \
      57              :             ##__VA_ARGS__);                                                                                      \
      58              :     }
      59              : #define AICPUE_LOGE(fmt, ...)                                                                                    \
      60              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                               \
      61              :         dlog_error(                                                                                              \
      62              :             static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), \
      63              :             ##__VA_ARGS__);                                                                                      \
      64              :     }
      65              : #define AICPUE_LOGD(fmt, ...)                                                                                    \
      66              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                               \
      67              :         dlog_debug(                                                                                              \
      68              :             static_cast<int32_t>(AICPU), "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), \
      69              :             ##__VA_ARGS__);                                                                                      \
      70              :     }
      71              : 
      72              : #define AICPUE_RUN_LOGW(fmt, ...)                                                                     \
      73              :     if ((&CheckLogLevel != nullptr) && (&DlogRecord != nullptr)) {                                    \
      74              :         dlog_warn(                                                                                    \
      75              :             static_cast<int32_t>(static_cast<uint32_t>(AICPU) | static_cast<uint32_t>(RUN_LOG_MASK)), \
      76              :             "[%s][tid:%ld][AICPU_SHARDER] " fmt, &__FUNCTION__[0], aicpu::GetTid(), ##__VA_ARGS__);   \
      77              :     }
      78              : 
      79              : #endif // endif AICPU_SHARDER_UTST
      80              : 
      81              : #endif
        

Generated by: LCOV version 2.0-1