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 % 13 13
Test Date: 2026-07-28 12:11:00 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              : #include "log.h"
      11              : 
      12              : thread_local bool g_hcclErrToWarn = false;
      13              : constexpr int32_t HCCL_LOG_LEVEL_INVALID = -1;
      14              : static int32_t g_logLevelCache = -1;
      15              : int32_t dlog_getlevel(int32_t moduleId, int32_t *enableEvent) __attribute((weak));
      16              : 
      17      2306036 : bool HcclCheckLogLevel(int logType, int moduleId)
      18              : {
      19      2306036 :     if ((moduleId & RUN_LOG_MASK) != 0) {
      20        91659 :         return true;
      21              :     }
      22      2214377 :     if (UNLIKELY(g_logLevelCache == HCCL_LOG_LEVEL_INVALID)) {
      23           41 :         int32_t enableEvent = -1;
      24           41 :         g_logLevelCache = dlog_getlevel(moduleId, &enableEvent);
      25              :     }
      26      2214377 :     return (logType >= g_logLevelCache);
      27              : }
      28              : 
      29            6 : void SetErrToWarnSwitch(bool flag)
      30              : {
      31            6 :     if (g_hcclErrToWarn != flag) {
      32            6 :         g_hcclErrToWarn = flag;
      33              :     }
      34            6 : }
      35              : 
      36        14520 : bool IsErrorToWarn()
      37              : {
      38        14520 :     return g_hcclErrToWarn;
      39              : }
        

Generated by: LCOV version 2.0-1