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 <cstdarg> 12 : #include <securec.h> 13 : #include "acl_rt_impl.h" 14 : #include "common/log_inner.h" 15 : 16 7 : void aclAppLogImpl(aclLogLevel logLevel, const char *func, const char *file, uint32_t line, const char *fmt, va_list args) 17 : { 18 7 : if ((fmt == nullptr) || (func == nullptr) || (file == nullptr)) { 19 0 : return; 20 : } 21 7 : if (!acl::AclLog::IsLogOutputEnable(logLevel)) { 22 0 : return; 23 : } 24 7 : char_t str[acl::MAX_LOG_STRING] = {}; 25 7 : int32_t printRet = vsnprintf_s(str, static_cast<size_t>(acl::MAX_LOG_STRING), 26 : static_cast<size_t>(acl::MAX_LOG_STRING - 1U), fmt, args); 27 7 : if (printRet != -1) { 28 5 : char_t strLog[acl::MAX_LOG_STRING] = {}; 29 5 : printRet = sprintf_s(strLog, static_cast<size_t>(acl::MAX_LOG_STRING), "%d %s:%s:%u: \"%s\"", 30 : acl::AclLog::GetTid(), func, file, line, str); 31 5 : if (printRet != -1) { 32 3 : acl::AclLog::ACLSaveLog(logLevel, strLog); 33 : } else { 34 2 : acl::AclLog::ACLSaveLog(ACL_ERROR, "aclAppLog call sprintf_s failed"); 35 : } 36 : } else { 37 2 : acl::AclLog::ACLSaveLog(ACL_ERROR, "aclAppLog call vsnprintf_s failed"); 38 : } 39 7 : return; 40 : }