spandsp 0.0.6
logging.h
Go to the documentation of this file.
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
26/*! \file */
27
28/*! \page logging_page Logging
29\section logging_page_sec_1 What does it do?
30???.
31*/
32
33#if !defined(_SPANDSP_LOGGING_H_)
34#define _SPANDSP_LOGGING_H_
35
36/*! General logging function for spandsp logging. */
37typedef void (*message_handler_func_t)(int level, const char *text);
38
39/*! Error logging function for spandsp logging. */
40typedef void (*error_handler_func_t)(const char *text);
41
42/* Logging elements */
43enum
44{
45 SPAN_LOG_SEVERITY_MASK = 0x00FF,
46 SPAN_LOG_SHOW_DATE = 0x0100,
47 SPAN_LOG_SHOW_SAMPLE_TIME = 0x0200,
48 SPAN_LOG_SHOW_SEVERITY = 0x0400,
49 SPAN_LOG_SHOW_PROTOCOL = 0x0800,
50 SPAN_LOG_SHOW_VARIANT = 0x1000,
51 SPAN_LOG_SHOW_TAG = 0x2000,
52 SPAN_LOG_SUPPRESS_LABELLING = 0x8000
53};
54
55/* Logging severity levels */
56enum
57{
58 SPAN_LOG_NONE = 0,
59 SPAN_LOG_ERROR = 1,
60 SPAN_LOG_WARNING = 2,
61 SPAN_LOG_PROTOCOL_ERROR = 3,
62 SPAN_LOG_PROTOCOL_WARNING = 4,
63 SPAN_LOG_FLOW = 5,
64 SPAN_LOG_FLOW_2 = 6,
65 SPAN_LOG_FLOW_3 = 7,
66 SPAN_LOG_DEBUG = 8,
67 SPAN_LOG_DEBUG_2 = 9,
68 SPAN_LOG_DEBUG_3 = 10
69};
70
71/*!
72 Logging descriptor. This defines the working state for a single instance of
73 the logging facility for spandsp.
74*/
76
77#if defined(__cplusplus)
78extern "C"
79{
80#endif
81
82/*! Test if logging of a specified severity level is enabled.
83 \brief Test if logging of a specified severity level is enabled.
84 \param s The logging context.
85 \param level The severity level to be tested.
86 \return TRUE if logging is enable, else FALSE.
87*/
88SPAN_DECLARE(int) span_log_test(logging_state_t *s, int level);
89
90/*! Generate a log entry.
91 \brief Generate a log entry.
92 \param s The logging context.
93 \param level The severity level of the entry.
94 \param format ???
95 \return 0 if no output generated, else 1.
96*/
97SPAN_DECLARE(int) span_log(logging_state_t *s, int level, const char *format, ...);
98
99/*! Generate a log entry displaying the contents of a buffer.
100 \brief Generate a log entry displaying the contents of a buffer
101 \param s The logging context.
102 \param level The severity level of the entry.
103 \param tag A label for the log entry.
104 \param buf The buffer to be dumped to the log.
105 \param len The length of buf.
106 \return 0 if no output generated, else 1.
107*/
108SPAN_DECLARE(int) span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len);
109
110SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level);
111
112SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag);
113
114SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol);
115
116SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_second);
117
118SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples);
119
120SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func);
121
122SPAN_DECLARE(void) span_log_set_error_handler(logging_state_t *s, error_handler_func_t func);
123
124SPAN_DECLARE(void) span_set_message_handler(message_handler_func_t func);
125
126SPAN_DECLARE(void) span_set_error_handler(error_handler_func_t func);
127
128SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, const char *tag);
129
130SPAN_DECLARE(int) span_log_release(logging_state_t *s);
131
132SPAN_DECLARE(int) span_log_free(logging_state_t *s);
133
134#if defined(__cplusplus)
135}
136#endif
137
138#endif
139/*- End of file ------------------------------------------------------------*/
void(* message_handler_func_t)(int level, const char *text)
Definition: logging.h:37
int span_log_test(logging_state_t *s, int level)
Test if logging of a specified severity level is enabled.
Definition: logging.c:76
void(* error_handler_func_t)(const char *text)
Definition: logging.h:40
int span_log(logging_state_t *s, int level, const char *format,...)
Generate a log entry.
Definition: logging.c:84
int span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len)
Generate a log entry displaying the contents of a buffer.
Definition: logging.c:158
Definition: private/logging.h:34