/* * Copyright (C) 2021 Amlogic Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __ATOOLS_LOGGER_H__ #define __ATOOLS_LOGGER_H__ #include #define LOG_LEVEL_ERROR 0 #define LOG_LEVEL_WARNING 1 #define LOG_LEVEL_INFO 2 #define LOG_LEVEL_DEBUG 3 #define LOG_LEVEL_TRACE 4 #define NO_CAT -1 /** * @brief init logger print * @param id plugin instance id * * @return category id */ int ALogger_init(int id); /** * @brief exit logger print * @param category category id * * @return */ void ALogger_exit(int category); void loggerPrint(int category, int level, const char *fmt, ... ); /** * @brief set log level * the log level from 0 ~ 4 * @param setLevel the log level * 0 - ERROR * 1.- WARN * 2.- INFO * 3.- DEBUG * 4.- TRACE */ void ALogger_set_level(int setLevel); /** * @brief get loger level * * @return int the log level from 0~6 */ int ALogger_get_level(); /** * @brief set log file,the filepath must is a absolute path, * if set filepath null, will close file and print log to stderr * the stderr is a default print out file * @param filepath the file absolute path */ void ALogger_set_file(char *filepath); void wl_log(const char *fmt, va_list arg); #define INT_ERROR(CAT,FORMAT, ...) loggerPrint(CAT,LOG_LEVEL_ERROR, "%s,%s:%d " FORMAT "\n",TAG,__func__, __LINE__, __VA_ARGS__) #define INT_WARNING(CAT,FORMAT, ...) loggerPrint(CAT,LOG_LEVEL_WARNING,"%s,%s:%d " FORMAT "\n",TAG,__func__, __LINE__, __VA_ARGS__) #define INT_INFO(CAT,FORMAT, ...) loggerPrint(CAT,LOG_LEVEL_INFO, "%s,%s:%d " FORMAT "\n",TAG,__func__, __LINE__, __VA_ARGS__) #define INT_DEBUG(CAT,FORMAT, ...) loggerPrint(CAT,LOG_LEVEL_DEBUG, "%s,%s:%d " FORMAT "\n",TAG,__func__, __LINE__, __VA_ARGS__) #define INT_TRACE(CAT,FORMAT, ...) loggerPrint(CAT,LOG_LEVEL_TRACE, "%s,%s:%d " FORMAT "\n",TAG,__func__, __LINE__, __VA_ARGS__) #define ERROR(CAT,...) INT_ERROR(CAT,__VA_ARGS__, "") #define WARNING(CAT,...) INT_WARNING(CAT,__VA_ARGS__, "") #define INFO(CAT,...) INT_INFO(CAT,__VA_ARGS__, "") #define DEBUG(CAT,...) INT_DEBUG(CAT,__VA_ARGS__, "") #define TRACE(CAT,...) INT_TRACE(CAT,__VA_ARGS__, "") #endif /*__ATOOLS_LOGGER_H__*/