00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef OLSR_LOGGING_H_
00043 #define OLSR_LOGGING_H_
00044
00045 #include "common/common_types.h"
00046 #include "common/list.h"
00047 #include "defs.h"
00048 #include "olsr_logging_sources.h"
00049
00050 #define LOGBUFFER_SIZE 1024
00051
00055 enum log_severity {
00056 SEVERITY_DEBUG,
00057 SEVERITY_INFO,
00058 SEVERITY_WARN,
00059 SEVERITY_ERR,
00060
00061
00062 LOG_SEVERITY_COUNT
00063 };
00064
00065 extern const char *LOG_SEVERITY_NAMES[];
00066
00084 #ifdef REMOVE_LOG_DEBUG
00085 #define OLSR_DEBUG(source, format, args...) do { } while(0)
00086 #define OLSR_DEBUG_NH(source, format, args...) do { } while(0)
00087 #else
00088 #define OLSR_DEBUG(source, format, args...) do { if (log_global_mask[SEVERITY_DEBUG][source]) olsr_log(SEVERITY_DEBUG, source, false, __FILE__, __LINE__, format, ##args); } while(0)
00089 #define OLSR_DEBUG_NH(source, format, args...) do { if (log_global_mask[SEVERITY_DEBUG][source]) olsr_log(SEVERITY_DEBUG, source, true, __FILE__, __LINE__, format, ##args); } while(0)
00090 #endif
00091
00092 #ifdef REMOVE_LOG_INFO
00093 #define OLSR_INFO(source, format, args...) do { } while(0)
00094 #define OLSR_INFO_NH(source, format, args...) do { } while(0)
00095 #else
00096 #define OLSR_INFO(source, format, args...) do { if (log_global_mask[SEVERITY_INFO][source]) olsr_log(SEVERITY_INFO, source, false, __FILE__, __LINE__, format, ##args); } while(0)
00097 #define OLSR_INFO_NH(source, format, args...) do { if (log_global_mask[SEVERITY_INFO][source]) olsr_log(SEVERITY_INFO, source, true, __FILE__, __LINE__, format, ##args); } while(0)
00098 #endif
00099
00100 #ifdef REMOVE_LOG_WARN
00101 #define OLSR_WARN(source, format, args...) do { } while(0)
00102 #define OLSR_WARN_NH(source, format, args...) do { } while(0)
00103 #else
00104 #define OLSR_WARN(source, format, args...) do { if (log_global_mask[SEVERITY_WARN][source]) olsr_log(SEVERITY_WARN, source, false, __FILE__, __LINE__, format, ##args); } while(0)
00105 #define OLSR_WARN_NH(source, format, args...) do { if (log_global_mask[SEVERITY_WARN][source]) olsr_log(SEVERITY_WARN, source, true, __FILE__, __LINE__, format, ##args); } while(0)
00106 #endif
00107
00108 #ifdef REMOVE_LOG_ERROR
00109 #define OLSR_ERROR(source, format, args...) do { } while(0)
00110 #define OLSR_ERROR_NH(source, format, args...) do { } while(0)
00111 #else
00112 #define OLSR_ERROR(source, format, args...) do { if (log_global_mask[SEVERITY_ERR][source]) olsr_log(SEVERITY_ERR, source, false, __FILE__, __LINE__, format, ##args); } while(0)
00113 #define OLSR_ERROR_NH(source, format, args...) do { if (log_global_mask[SEVERITY_ERR][source]) olsr_log(SEVERITY_ERR, source, true, __FILE__, __LINE__, format, ##args); } while(0)
00114 #endif
00115
00116 struct log_handler_entry {
00117 struct list_entity node;
00118 void (*handler)(enum log_severity, enum log_source,
00119 bool, const char *, int, char *, int, int);
00120
00121
00122 bool(*bitmask_ptr)[LOG_SEVERITY_COUNT][LOG_SOURCE_COUNT];
00123
00124
00125 bool int_bitmask[LOG_SEVERITY_COUNT][LOG_SOURCE_COUNT];
00126 };
00127
00128 void EXPORT(olsr_log_init) (void);
00129 void EXPORT(olsr_log_cleanup) (void);
00130
00131 void EXPORT(olsr_log_applyconfig) (void);
00132
00133 struct log_handler_entry * EXPORT(olsr_log_addhandler) (void (*handler) (enum log_severity, enum log_source, bool,
00134 const char *, int, char *, int, int),
00135 bool(*mask)[LOG_SEVERITY_COUNT][LOG_SOURCE_COUNT]);
00136 void EXPORT(olsr_log_removehandler) (struct log_handler_entry *);
00137 void EXPORT(olsr_log_updatemask) (void);
00138
00139 void EXPORT(olsr_log) (enum log_severity, enum log_source, bool, const char *, int, const char *, ...)
00140 __attribute__ ((format(printf, 6, 7)));
00141
00142 extern bool EXPORT(log_global_mask)[LOG_SEVERITY_COUNT][LOG_SOURCE_COUNT];
00143
00144 #endif