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