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