00001 #ifndef LOGGING_H 00002 #define LOGGING_H 00003 00004 /*****************************************************************************/ 00005 /******************************** Documentation ******************************/ 00006 /*****************************************************************************/ 00007 00008 /** 00009 * \file 00010 * Public interface for logging routines. 00011 */ 00012 00013 /*****************************************************************************/ 00014 /******************************* Include Files *******************************/ 00015 /*****************************************************************************/ 00016 00017 /*****************************************************************************/ 00018 /*********************************** Defines *********************************/ 00019 /*****************************************************************************/ 00020 00021 /** 00022 * \name Logging Levels 00023 * @{ 00024 */ 00025 #define LOG_ERROR 1 /**< emit messages at ERROR level */ 00026 #define LOG_WARN 2 /**< emit messages at WARN level and above */ 00027 #define LOG_INFO 3 /**< emit messages at INFO level and above */ 00028 #define LOG_DEBUG 4 /**< emit messages at DEBUG level and above */ 00029 #define LOG_VERBOSE_DEBUG 5 /**< emit messages at VERBOSE DEBUG level and above */ 00030 /* @} */ 00031 00032 /** 00033 * Format a log message using printf style arguments at the specfied logging level 00034 * 00035 * \param[in] level The logging level associated with this message. 00036 * \param[in] ... Printf style arguments starting with format string. 00037 * 00038 * In addition to formatting the log message this macro adds information to a 00039 * lower level logging routine which specifies the location of the message in 00040 * the code: 00041 * - the source code file name 00042 * - the line number in the source code file 00043 * - the name of the containing function 00044 * 00045 * Whether the information describing the position of the message is included in 00046 * the emitted log message is controlled by several logging flags. 00047 * \see log_set_show_file() 00048 * \see log_set_show_line() 00049 * \see log_set_show_function() 00050 */ 00051 #define log_msg(level, ...) log_msg1(level, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) 00052 00053 /*****************************************************************************/ 00054 /******************************* Type Definitions ****************************/ 00055 /*****************************************************************************/ 00056 00057 /*****************************************************************************/ 00058 /************************* External Global Variables ***********************/ 00059 /*****************************************************************************/ 00060 00061 /*****************************************************************************/ 00062 /**************************** Exported Functions ***************************/ 00063 /*****************************************************************************/ 00064 00065 int log_init(void); 00066 int log_fini(void); 00067 int log_close(void); 00068 int log_close_file(void); 00069 int log_set_filepath(const char *path); 00070 int log_set_level(int level); 00071 int log_to_console(bool flag); 00072 int log_to_file(bool flag); 00073 int log_set_show_level(bool show); 00074 int log_set_show_file(bool show); 00075 int log_set_show_line(bool show); 00076 int log_set_show_function(bool show); 00077 int log_set_show_time(bool show); 00078 int log_set_time_format(const char *format); 00079 void log_msg1(int level, const char *file, int line, const char *function, const char *fmt, ...); 00080 int log_level_from_string(const char *level_str, int *log_level); 00081 00082 #endif