spandsp 0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * logging.h - definitions for error and debug logging. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2005 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 /*! \file */ 00027 00028 /*! \page logging_page Logging 00029 \section logging_page_sec_1 What does it do? 00030 ???. 00031 */ 00032 00033 #if !defined(_SPANDSP_LOGGING_H_) 00034 #define _SPANDSP_LOGGING_H_ 00035 00036 /*! General logging function for spandsp logging. */ 00037 typedef void (*message_handler_func_t)(int level, const char *text); 00038 00039 /*! Error logging function for spandsp logging. */ 00040 typedef void (*error_handler_func_t)(const char *text); 00041 00042 /* Logging elements */ 00043 enum 00044 { 00045 SPAN_LOG_SEVERITY_MASK = 0x00FF, 00046 SPAN_LOG_SHOW_DATE = 0x0100, 00047 SPAN_LOG_SHOW_SAMPLE_TIME = 0x0200, 00048 SPAN_LOG_SHOW_SEVERITY = 0x0400, 00049 SPAN_LOG_SHOW_PROTOCOL = 0x0800, 00050 SPAN_LOG_SHOW_VARIANT = 0x1000, 00051 SPAN_LOG_SHOW_TAG = 0x2000, 00052 SPAN_LOG_SUPPRESS_LABELLING = 0x8000 00053 }; 00054 00055 /* Logging severity levels */ 00056 enum 00057 { 00058 SPAN_LOG_NONE = 0, 00059 SPAN_LOG_ERROR = 1, 00060 SPAN_LOG_WARNING = 2, 00061 SPAN_LOG_PROTOCOL_ERROR = 3, 00062 SPAN_LOG_PROTOCOL_WARNING = 4, 00063 SPAN_LOG_FLOW = 5, 00064 SPAN_LOG_FLOW_2 = 6, 00065 SPAN_LOG_FLOW_3 = 7, 00066 SPAN_LOG_DEBUG = 8, 00067 SPAN_LOG_DEBUG_2 = 9, 00068 SPAN_LOG_DEBUG_3 = 10 00069 }; 00070 00071 /*! 00072 Logging descriptor. This defines the working state for a single instance of 00073 the logging facility for spandsp. 00074 */ 00075 typedef struct logging_state_s logging_state_t; 00076 00077 #if defined(__cplusplus) 00078 extern "C" 00079 { 00080 #endif 00081 00082 /*! Test if logging of a specified severity level is enabled. 00083 \brief Test if logging of a specified severity level is enabled. 00084 \param s The logging context. 00085 \param level The severity level to be tested. 00086 \return TRUE if logging is enable, else FALSE. 00087 */ 00088 SPAN_DECLARE(int) span_log_test(logging_state_t *s, int level); 00089 00090 /*! Generate a log entry. 00091 \brief Generate a log entry. 00092 \param s The logging context. 00093 \param level The severity level of the entry. 00094 \param format ??? 00095 \return 0 if no output generated, else 1. 00096 */ 00097 SPAN_DECLARE(int) span_log(logging_state_t *s, int level, const char *format, ...); 00098 00099 /*! Generate a log entry displaying the contents of a buffer. 00100 \brief Generate a log entry displaying the contents of a buffer 00101 \param s The logging context. 00102 \param level The severity level of the entry. 00103 \param tag A label for the log entry. 00104 \param buf The buffer to be dumped to the log. 00105 \param len The length of buf. 00106 \return 0 if no output generated, else 1. 00107 */ 00108 SPAN_DECLARE(int) span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len); 00109 00110 SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level); 00111 00112 SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag); 00113 00114 SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol); 00115 00116 SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_second); 00117 00118 SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples); 00119 00120 SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func); 00121 00122 SPAN_DECLARE(void) span_log_set_error_handler(logging_state_t *s, error_handler_func_t func); 00123 00124 SPAN_DECLARE(void) span_set_message_handler(message_handler_func_t func); 00125 00126 SPAN_DECLARE(void) span_set_error_handler(error_handler_func_t func); 00127 00128 SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, const char *tag); 00129 00130 SPAN_DECLARE(int) span_log_release(logging_state_t *s); 00131 00132 SPAN_DECLARE(int) span_log_free(logging_state_t *s); 00133 00134 #if defined(__cplusplus) 00135 } 00136 #endif 00137 00138 #endif 00139 /*- End of file ------------------------------------------------------------*/