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