comparison spandsp-0.0.6pre17/src/spandsp/logging.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
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 Lesser General Public License version 2.1,
14 * as 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 Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License 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.20 2009/02/10 17:44:18 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(_SPANDSP_LOGGING_H_)
36 #define _SPANDSP_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 logging_state_s logging_state_t;
78
79 #if defined(__cplusplus)
80 extern "C"
81 {
82 #endif
83
84 /*! Test if logging of a specified severity level is enabled.
85 \brief Test if logging of a specified severity level is enabled.
86 \param s The logging context.
87 \param level The severity level to be tested.
88 \return TRUE if logging is enable, else FALSE.
89 */
90 SPAN_DECLARE(int) span_log_test(logging_state_t *s, int level);
91
92 /*! Generate a log entry.
93 \brief Generate a log entry.
94 \param s The logging context.
95 \param level The severity level of the entry.
96 \param format ???
97 \return 0 if no output generated, else 1.
98 */
99 SPAN_DECLARE(int) span_log(logging_state_t *s, int level, const char *format, ...);
100
101 /*! Generate a log entry displaying the contents of a buffer.
102 \brief Generate a log entry displaying the contents of a buffer
103 \param s The logging context.
104 \param level The severity level of the entry.
105 \param tag A label for the log entry.
106 \param buf The buffer to be dumped to the log.
107 \param len The length of buf.
108 \return 0 if no output generated, else 1.
109 */
110 SPAN_DECLARE(int) span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len);
111
112 SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level);
113
114 SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag);
115
116 SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol);
117
118 SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_second);
119
120 SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples);
121
122 SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func);
123
124 SPAN_DECLARE(void) span_log_set_error_handler(logging_state_t *s, error_handler_func_t func);
125
126 SPAN_DECLARE(void) span_set_message_handler(message_handler_func_t func);
127
128 SPAN_DECLARE(void) span_set_error_handler(error_handler_func_t func);
129
130 SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, const char *tag);
131
132 SPAN_DECLARE(int) span_log_release(logging_state_t *s);
133
134 SPAN_DECLARE(int) span_log_free(logging_state_t *s);
135
136 #if defined(__cplusplus)
137 }
138 #endif
139
140 #endif
141 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.