1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __LOG_BASE_H__ 17 #define __LOG_BASE_H__ 18 19 #include <stdio.h> 20 21 void LogErr(const char* format, ...); 22 void LogWarn(const char* format, ...); 23 void LogInfo(const char* format, ...); 24 void LogDebug(const char* format, ...); 25 26 int GetFFRTLogLevel(void); 27 28 #define FFRT_LOG(level, format, ...) \ 29 do { \ 30 if ((level) > GetFFRTLogLevel()) \ 31 break; \ 32 if (level == FFRT_LOG_ERROR) { \ 33 LogErr("%u:%s:%d " format "\n", GetLogId(), __func__, __LINE__, ##__VA_ARGS__); \ 34 } else if (level == FFRT_LOG_WARN) { \ 35 LogWarn("%u:%s:%d " format "\n", GetLogId(), __func__, __LINE__, ##__VA_ARGS__); \ 36 } else if (level == FFRT_LOG_INFO) { \ 37 LogInfo("%u:%s:%d " format "\n", GetLogId(), __func__, __LINE__, ##__VA_ARGS__); \ 38 } else if (level == FFRT_LOG_DEBUG) { \ 39 LogDebug("%u:%s:%d " format "\n", GetLogId(), __func__, __LINE__, ##__VA_ARGS__); \ 40 } else { \ 41 printf("Log Level is Invalid!"); \ 42 } \ 43 } while (0) 44 45 #endif // __LOG_BASE_H__