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 #ifndef _ASTERISK_LOGGER_H
00026 #define _ASTERISK_LOGGER_H
00027
00028 #include "asterisk/options.h"
00029
00030 #if defined(__cplusplus) || defined(c_plusplus)
00031 extern "C" {
00032 #endif
00033
00034 #define EVENTLOG "event_log"
00035 #define QUEUELOG "queue_log"
00036
00037 #define DEBUG_M(a) { \
00038 a; \
00039 }
00040
00041 #define VERBOSE_PREFIX_1 " "
00042 #define VERBOSE_PREFIX_2 " == "
00043 #define VERBOSE_PREFIX_3 " -- "
00044 #define VERBOSE_PREFIX_4 " > "
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
00061 __attribute__((format(printf, 5, 6)));
00062
00063 void ast_backtrace(void);
00064
00065
00066 int logger_reload(void);
00067
00068 void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
00069
00070
00071
00072
00073
00074
00075
00076
00077 void __attribute__((format(printf, 4, 5))) __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
00078
00079 #define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
00080
00081 void __attribute__((format(printf, 4, 0))) __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap);
00082
00083 #define ast_verbose_ap(fmt, ap) __ast_verbose_ap(__FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ap)
00084
00085 void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
00086
00087 int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
00088 int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
00089
00090 void ast_console_puts(const char *string);
00091
00092
00093
00094
00095
00096
00097 void ast_console_puts_mutable(const char *string, int level);
00098 void ast_console_toggle_mute(int fd, int silent);
00099
00100
00101
00102
00103 void ast_console_toggle_loglevel(int fd, int level, int state);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
00114
00115 #ifdef LOG_DEBUG
00116 #undef LOG_DEBUG
00117 #endif
00118 #define __LOG_DEBUG 0
00119 #define LOG_DEBUG __LOG_DEBUG, _A_
00120
00121 #ifdef AST_LOG_DEBUG
00122 #undef AST_LOG_DEBUG
00123 #endif
00124 #define AST_LOG_DEBUG __LOG_DEBUG, _A_
00125
00126 #ifdef LOG_EVENT
00127 #undef LOG_EVENT
00128 #endif
00129 #define __LOG_EVENT 1
00130 #define LOG_EVENT __LOG_EVENT, _A_
00131
00132 #ifdef AST_LOG_EVENT
00133 #undef AST_LOG_EVENT
00134 #endif
00135 #define AST_LOG_EVENT __LOG_EVENT, _A_
00136
00137 #ifdef LOG_NOTICE
00138 #undef LOG_NOTICE
00139 #endif
00140 #define __LOG_NOTICE 2
00141 #define LOG_NOTICE __LOG_NOTICE, _A_
00142
00143 #ifdef AST_LOG_NOTICE
00144 #undef AST_LOG_NOTICE
00145 #endif
00146 #define AST_LOG_NOTICE __LOG_NOTICE, _A_
00147
00148 #ifdef LOG_WARNING
00149 #undef LOG_WARNING
00150 #endif
00151 #define __LOG_WARNING 3
00152 #define LOG_WARNING __LOG_WARNING, _A_
00153
00154 #ifdef AST_LOG_WARNING
00155 #undef AST_LOG_WARNING
00156 #endif
00157 #define AST_LOG_WARNING __LOG_WARNING, _A_
00158
00159 #ifdef LOG_ERROR
00160 #undef LOG_ERROR
00161 #endif
00162 #define __LOG_ERROR 4
00163 #define LOG_ERROR __LOG_ERROR, _A_
00164
00165 #ifdef AST_LOG_ERROR
00166 #undef AST_LOG_ERROR
00167 #endif
00168 #define AST_LOG_ERROR __LOG_ERROR, _A_
00169
00170 #ifdef LOG_VERBOSE
00171 #undef LOG_VERBOSE
00172 #endif
00173 #define __LOG_VERBOSE 5
00174 #define LOG_VERBOSE __LOG_VERBOSE, _A_
00175
00176 #ifdef AST_LOG_VERBOSE
00177 #undef AST_LOG_VERBOSE
00178 #endif
00179 #define LOG_VERBOSE __LOG_VERBOSE, _A_
00180
00181 #ifdef LOG_DTMF
00182 #undef LOG_DTMF
00183 #endif
00184 #define __LOG_DTMF 6
00185 #define LOG_DTMF __LOG_DTMF, _A_
00186
00187 #ifdef AST_LOG_DTMF
00188 #undef AST_LOG_DTMF
00189 #endif
00190 #define AST_LOG_DTMF __LOG_DTMF, _A_
00191
00192 #define NUMLOGLEVELS 6
00193
00194
00195
00196
00197
00198
00199 unsigned int ast_debug_get_by_file(const char *file);
00200
00201
00202
00203
00204
00205
00206 unsigned int ast_verbose_get_by_file(const char *file);
00207
00208
00209
00210
00211
00212
00213 #define ast_debug(level, ...) do { \
00214 if (option_debug >= (level) || (ast_opt_dbg_file && ast_debug_get_by_file(__FILE__) >= (level)) ) \
00215 ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
00216 } while (0)
00217
00218 #define VERBOSITY_ATLEAST(level) (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)))
00219
00220 #define ast_verb(level, ...) do { \
00221 if (VERBOSITY_ATLEAST((level)) ) { \
00222 if (level >= 4) \
00223 ast_verbose(VERBOSE_PREFIX_4 __VA_ARGS__); \
00224 else if (level == 3) \
00225 ast_verbose(VERBOSE_PREFIX_3 __VA_ARGS__); \
00226 else if (level == 2) \
00227 ast_verbose(VERBOSE_PREFIX_2 __VA_ARGS__); \
00228 else if (level == 1) \
00229 ast_verbose(VERBOSE_PREFIX_1 __VA_ARGS__); \
00230 else \
00231 ast_verbose(__VA_ARGS__); \
00232 } \
00233 } while (0)
00234
00235 #ifndef _LOGGER_BACKTRACE_H
00236 #define _LOGGER_BACKTRACE_H
00237 #ifdef HAVE_BKTR
00238 #define AST_MAX_BT_FRAMES 32
00239
00240
00241
00242
00243
00244 struct ast_bt {
00245
00246 void *addresses[AST_MAX_BT_FRAMES];
00247
00248 int num_frames;
00249
00250 unsigned int alloced:1;
00251 };
00252
00253
00254
00255
00256
00257
00258
00259 struct ast_bt *ast_bt_create(void);
00260
00261
00262
00263
00264
00265
00266
00267
00268 int ast_bt_get_addresses(struct ast_bt *bt);
00269
00270
00271
00272
00273
00274
00275
00276
00277 void *ast_bt_destroy(struct ast_bt *bt);
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 char **ast_bt_get_symbols(void **addresses, size_t num_frames);
00288
00289 #endif
00290 #endif
00291
00292 #if defined(__cplusplus) || defined(c_plusplus)
00293 }
00294 #endif
00295
00296 #endif