LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/common - log.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 12 12
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 3 3

            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              : 
      13              : thread_local bool g_hcclErrToWarn = false;
      14              : constexpr int32_t HCCL_LOG_LEVEL_INVALID = -1;
      15              : static int32_t g_logLevelCache = -1;
      16              : int32_t dlog_getlevel(int32_t moduleId, int32_t* enableEvent) __attribute((weak));
      17              : 
      18      2328444 : bool HcclCheckLogLevel(int logType, int moduleId)
      19              : {
      20      2328444 :     if ((moduleId & RUN_LOG_MASK) != 0) {
      21        95916 :         return true;
      22              :     }
      23      2232528 :     if (UNLIKELY(g_logLevelCache == HCCL_LOG_LEVEL_INVALID)) {
      24           47 :         int32_t enableEvent = -1;
      25           47 :         g_logLevelCache = dlog_getlevel(moduleId, &enableEvent);
      26              :     }
      27      2232528 :     return (logType >= g_logLevelCache);
      28              : }
      29              : 
      30            6 : void SetErrToWarnSwitch(bool flag)
      31              : {
      32            6 :     if (g_hcclErrToWarn != flag) {
      33            6 :         g_hcclErrToWarn = flag;
      34              :     }
      35            6 : }
      36              : 
      37        15213 : bool IsErrorToWarn() { return g_hcclErrToWarn; }
        

Generated by: LCOV version 2.0-1