logging.h
Go to the documentation of this file.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 #if !defined(_SPANDSP_LOGGING_H_)
00036 #define _SPANDSP_LOGGING_H_
00037
00038
00039 typedef void (*message_handler_func_t)(int level, const char *text);
00040
00041
00042 typedef void (*error_handler_func_t)(const char *text);
00043
00044
00045 enum
00046 {
00047 SPAN_LOG_SEVERITY_MASK = 0x00FF,
00048 SPAN_LOG_SHOW_DATE = 0x0100,
00049 SPAN_LOG_SHOW_SAMPLE_TIME = 0x0200,
00050 SPAN_LOG_SHOW_SEVERITY = 0x0400,
00051 SPAN_LOG_SHOW_PROTOCOL = 0x0800,
00052 SPAN_LOG_SHOW_VARIANT = 0x1000,
00053 SPAN_LOG_SHOW_TAG = 0x2000,
00054 SPAN_LOG_SUPPRESS_LABELLING = 0x8000
00055 };
00056
00057
00058 enum
00059 {
00060 SPAN_LOG_NONE = 0,
00061 SPAN_LOG_ERROR = 1,
00062 SPAN_LOG_WARNING = 2,
00063 SPAN_LOG_PROTOCOL_ERROR = 3,
00064 SPAN_LOG_PROTOCOL_WARNING = 4,
00065 SPAN_LOG_FLOW = 5,
00066 SPAN_LOG_FLOW_2 = 6,
00067 SPAN_LOG_FLOW_3 = 7,
00068 SPAN_LOG_DEBUG = 8,
00069 SPAN_LOG_DEBUG_2 = 9,
00070 SPAN_LOG_DEBUG_3 = 10
00071 };
00072
00073
00074
00075
00076
00077 typedef struct
00078 {
00079 int level;
00080 int samples_per_second;
00081 int64_t elapsed_samples;
00082 const char *tag;
00083 const char *protocol;
00084
00085 message_handler_func_t span_message;
00086 error_handler_func_t span_error;
00087 } logging_state_t;
00088
00089 #if defined(__cplusplus)
00090 extern "C"
00091 {
00092 #endif
00093
00094
00095
00096
00097
00098
00099
00100 int span_log_test(logging_state_t *s, int level);
00101
00102
00103
00104
00105
00106
00107
00108
00109 int span_log(logging_state_t *s, int level, const char *format, ...);
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 int span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len);
00121
00122 int span_log_init(logging_state_t *s, int level, const char *tag);
00123
00124 int span_log_set_level(logging_state_t *s, int level);
00125
00126 int span_log_set_tag(logging_state_t *s, const char *tag);
00127
00128 int span_log_set_protocol(logging_state_t *s, const char *protocol);
00129
00130 int span_log_set_sample_rate(logging_state_t *s, int samples_per_second);
00131
00132 int span_log_bump_samples(logging_state_t *s, int samples);
00133
00134 void span_log_set_message_handler(logging_state_t *s, message_handler_func_t func);
00135
00136 void span_log_set_error_handler(logging_state_t *s, error_handler_func_t func);
00137
00138 void span_set_message_handler(message_handler_func_t func);
00139
00140 void span_set_error_handler(error_handler_func_t func);
00141
00142 #if defined(__cplusplus)
00143 }
00144 #endif
00145
00146 #endif
00147