LCOV - code coverage report
Current view: top level - legacy/ascend950/common - log.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 88.4 % 43 38
Test Date: 2026-08-29 17:38:31 Functions: 87.5 % 8 7

            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              : #include "log.h"
      12              : #include <dlog_pub.h>
      13              : 
      14              : namespace Hccl {
      15              : #ifndef CCL_KERNEL
      16        60639 : int HcclCheckLogLevel(int logLevel)
      17              : {
      18        60639 :     if (logLevel == HCCL_LOG_RUN_INFO) {
      19          997 :         return CheckLogLevel(HCCL | RUN_LOG_MASK, DLOG_INFO);
      20        59642 :     } else if (logLevel == HCCL_LOG_RUN_WARN) {
      21            1 :         return CheckLogLevel(HCCL | RUN_LOG_MASK, DLOG_WARN);
      22              :     } else {
      23        59641 :         return CheckLogLevel(HCCL, logLevel);
      24              :     }
      25              : }
      26              : 
      27            0 : bool CheckDebugLogLevel() { return CheckLogLevel(HCCL, DLOG_DEBUG) == 1; }
      28              : 
      29            1 : bool CheckInfoLogLevel() { return CheckLogLevel(HCCL, DLOG_INFO) == 1; }
      30              : 
      31            2 : void CallDlogInvalidType(int level, int errCode, std::string file, int line)
      32              : {
      33            2 :     if (level == HCCL_LOG_RUN_INFO) {
      34            1 :         LOG_FUNC(
      35              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_INFO, "[%s:%d][Log] Invalid LogType:Mod[%s],Type[%u]\n",
      36              :             file.c_str(), line, "HCCL", errCode);
      37            1 :     } else if (level == HCCL_LOG_RUN_WARN) {
      38            0 :         LOG_FUNC(
      39              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_WARN, "[%s:%d][Log] Invalid LogType:Mod[%s],Type[%u]\n",
      40              :             file.c_str(), line, "HCCL", errCode);
      41              :     } else {
      42            1 :         LOG_FUNC(HCCL, level, "[%s:%d][Log] Invalid LogType:Mod[%s],Type[%u]\n", file.c_str(), line, "HCCL", errCode);
      43              :     }
      44            2 : }
      45              : 
      46            7 : void CallDlogNoSzFormat(int level, int errCode, std::string file, int line)
      47              : {
      48            7 :     if (level == HCCL_LOG_RUN_INFO) {
      49            1 :         LOG_FUNC(
      50              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_INFO, "[%s:%d]errNo[0x%016llx] ptr of szFormat is null\n",
      51              :             file.c_str(), line, errCode);
      52            6 :     } else if (level == HCCL_LOG_RUN_WARN) {
      53            0 :         LOG_FUNC(
      54              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_WARN, "[%s:%d]errNo[0x%016llx] ptr of szFormat is null\n",
      55              :             file.c_str(), line, errCode);
      56              :     } else {
      57            6 :         LOG_FUNC(HCCL, level, "[%s:%d]errNo[0x%016llx] ptr of szFormat is null\n", file.c_str(), line, errCode);
      58              :     }
      59            7 : }
      60              : 
      61           24 : void CallDlogMemError(int level, std::string file, int line)
      62              : {
      63           24 :     if (level == HCCL_LOG_RUN_INFO) {
      64            1 :         LOG_FUNC(
      65              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_INFO, "[%s:%d]memset stack log buffer to 0 failed.\n",
      66              :             file.c_str(), line);
      67           23 :     } else if (level == HCCL_LOG_RUN_WARN) {
      68            0 :         LOG_FUNC(
      69              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_WARN, "[%s:%d]memset stack log buffer to 0 failed.\n",
      70              :             file.c_str(), line);
      71              :     } else {
      72           23 :         LOG_FUNC(HCCL, level, "[%s:%d]memset stack log buffer to 0 failed.\n", file.c_str(), line);
      73              :     }
      74           24 : }
      75              : 
      76            2 : void CallDlogPrintError(int level, std::string file, int line)
      77              : {
      78            2 :     if (level == HCCL_LOG_RUN_INFO) {
      79            1 :         LOG_FUNC(static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_INFO, "[%s:%d]snprintf_s failed.\n", file.c_str(), line);
      80            1 :     } else if (level == HCCL_LOG_RUN_WARN) {
      81            0 :         LOG_FUNC(static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_WARN, "[%s:%d]snprintf_s failed.\n", file.c_str(), line);
      82              :     } else {
      83            1 :         LOG_FUNC(HCCL, level, "[%s:%d]snprintf_s failed.\n", file.c_str(), line);
      84              :     }
      85            2 : }
      86              : 
      87        60858 : void CallDlog(int level, int sysCallBack, const char* buffer, std::string file, int line)
      88              : {
      89        60858 :     if (level == HCCL_LOG_RUN_INFO) {
      90          997 :         LOG_FUNC(
      91              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_INFO, "[%s:%d][%u]%s\n", file.c_str(), line, sysCallBack,
      92              :             buffer);
      93        59861 :     } else if (level == HCCL_LOG_RUN_WARN) {
      94            1 :         LOG_FUNC(
      95              :             static_cast<u32>(HCCL) | RUN_LOG_MASK, DLOG_WARN, "[%s:%d][%u]%s\n", file.c_str(), line, sysCallBack,
      96              :             buffer);
      97              :     } else {
      98        59860 :         LOG_FUNC(HCCL, level, "[%s:%d][%u]%s\n", file.c_str(), line, sysCallBack, buffer);
      99              :     }
     100        60837 : }
     101              : #endif
     102              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1