5
|
1 /*
|
|
2 * SpanDSP - a series of DSP components for telephony
|
|
3 *
|
|
4 * logging.h - definitions for error and debug logging.
|
|
5 *
|
|
6 * Written by Steve Underwood <steveu@coppice.org>
|
|
7 *
|
|
8 * Copyright (C) 2005 Steve Underwood
|
|
9 *
|
|
10 * All rights reserved.
|
|
11 *
|
|
12 * This program is free software; you can redistribute it and/or modify
|
|
13 * it under the terms of the GNU General Public License version 2, as
|
|
14 * published by the Free Software Foundation.
|
|
15 *
|
|
16 * This program is distributed in the hope that it will be useful,
|
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 * GNU General Public License for more details.
|
|
20 *
|
|
21 * You should have received a copy of the GNU General Public License
|
|
22 * along with this program; if not, write to the Free Software
|
|
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24 *
|
|
25 * $Id: logging.h,v 1.10 2006/10/24 13:45:28 steveu Exp $
|
|
26 */
|
|
27
|
|
28 /*! \file */
|
|
29
|
|
30 /*! \page logging_page Logging
|
|
31 \section logging_page_sec_1 What does it do?
|
|
32 ???.
|
|
33 */
|
|
34
|
|
35 #if !defined(_LOGGING_H_)
|
|
36 #define _LOGGING_H_
|
|
37
|
|
38 /*! General logging function for spandsp logging. */
|
|
39 typedef void (*message_handler_func_t)(int level, const char *text);
|
|
40
|
|
41 /*! Error logging function for spandsp logging. */
|
|
42 typedef void (*error_handler_func_t)(const char *text);
|
|
43
|
|
44 /* Logging elements */
|
|
45 enum
|
|
46 {
|
|
47 SPAN_LOG_SEVERITY_MASK = 0x00FF,
|
|
48 SPAN_LOG_SHOW_DATE = 0x0100,
|
|
49 SPAN_LOG_SHOW_SAMPLE_TIME = 0x0200,
|
|
50 SPAN_LOG_SHOW_SEVERITY = 0x0400,
|
|
51 SPAN_LOG_SHOW_PROTOCOL = 0x0800,
|
|
52 SPAN_LOG_SHOW_VARIANT = 0x1000,
|
|
53 SPAN_LOG_SHOW_TAG = 0x2000,
|
|
54 SPAN_LOG_SUPPRESS_LABELLING = 0x8000
|
|
55 };
|
|
56
|
|
57 /* Logging severity levels */
|
|
58 enum
|
|
59 {
|
|
60 SPAN_LOG_NONE = 0,
|
|
61 SPAN_LOG_ERROR = 1,
|
|
62 SPAN_LOG_WARNING = 2,
|
|
63 SPAN_LOG_PROTOCOL_ERROR = 3,
|
|
64 SPAN_LOG_PROTOCOL_WARNING = 4,
|
|
65 SPAN_LOG_FLOW = 5,
|
|
66 SPAN_LOG_FLOW_2 = 6,
|
|
67 SPAN_LOG_FLOW_3 = 7,
|
|
68 SPAN_LOG_DEBUG = 8,
|
|
69 SPAN_LOG_DEBUG_2 = 9,
|
|
70 SPAN_LOG_DEBUG_3 = 10
|
|
71 };
|
|
72
|
|
73 /*!
|
|
74 Logging descriptor. This defines the working state for a single instance of
|
|
75 the logging facility for spandsp.
|
|
76 */
|
|
77 typedef struct
|
|
78 {
|
|
79 int level;
|
|
80 int samples_per_second;
|
|
81 int64_t elapsed_samples;
|
|
82 const char *tag;
|
|
83 const char *protocol;
|
|
84
|
|
85 message_handler_func_t span_message;
|
|
86 error_handler_func_t span_error;
|
|
87 } logging_state_t;
|
|
88
|
|
89 #ifdef __cplusplus
|
|
90 extern "C" {
|
|
91 #endif
|
|
92
|
|
93 /*! Test if logging of a specified severity level is enabled.
|
|
94 \brief Test if logging of a specified severity level is enabled.
|
|
95 \param s The logging context.
|
|
96 \param level The severity level to be tested.
|
|
97 \return TRUE if logging is enable, else FALSE.
|
|
98 */
|
|
99 int span_log_test(logging_state_t *s, int level);
|
|
100
|
|
101 /*! Generate a log entry.
|
|
102 \brief Generate a log entry.
|
|
103 \param s The logging context.
|
|
104 \param level The severity level of the entry.
|
|
105 \param format ???
|
|
106 \return 0 if no output generated, else 1.
|
|
107 */
|
|
108 int span_log(logging_state_t *s, int level, const char *format, ...);
|
|
109
|
|
110 /*! Generate a log entry displaying the contents of a buffer.
|
|
111 \brief Generate a log entry displaying the contents of a buffer
|
|
112 \param s The logging context.
|
|
113 \param level The severity level of the entry.
|
|
114 \param tag A label for the log entry.
|
|
115 \param buf The buffer to be dumped to the log.
|
|
116 \param len The length of buf.
|
|
117 \return 0 if no output generated, else 1.
|
|
118 */
|
|
119 int span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len);
|
|
120
|
|
121 int span_log_init(logging_state_t *s, int level, const char *tag);
|
|
122
|
|
123 int span_log_set_level(logging_state_t *s, int level);
|
|
124
|
|
125 int span_log_set_tag(logging_state_t *s, const char *tag);
|
|
126
|
|
127 int span_log_set_protocol(logging_state_t *s, const char *protocol);
|
|
128
|
|
129 int span_log_set_sample_rate(logging_state_t *s, int samples_per_second);
|
|
130
|
|
131 int span_log_bump_samples(logging_state_t *s, int samples);
|
|
132
|
|
133 void span_log_set_message_handler(logging_state_t *s, message_handler_func_t func);
|
|
134
|
|
135 void span_log_set_error_handler(logging_state_t *s, error_handler_func_t func);
|
|
136
|
|
137 void span_set_message_handler(message_handler_func_t func);
|
|
138
|
|
139 void span_set_error_handler(error_handler_func_t func);
|
|
140
|
|
141 #ifdef __cplusplus
|
|
142 }
|
|
143 #endif
|
|
144
|
|
145 #endif
|
|
146 /*- End of file ------------------------------------------------------------*/
|