logging.h

Go to the documentation of this file.
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 General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: logging.h,v 1.5 2006/01/15 08:13:30 steveu Exp $
00027  */
00028 
00029 /*! \file */
00030 
00031 /*! \page logging_page Logging
00032 \section logging_page_sec_1 What does it do?
00033 ???.
00034 */
00035 
00036 #if !defined(_LOGGING_H_)
00037 #define _LOGGING_H_
00038 
00039 /* Logging elements */
00040 #define SPAN_LOG_SEVERITY_MASK          0x00FF
00041 #define SPAN_LOG_SHOW_DATE              0x0100
00042 #define SPAN_LOG_SHOW_SEVERITY          0x0200
00043 #define SPAN_LOG_SHOW_PROTOCOL          0x0400
00044 #define SPAN_LOG_SHOW_VARIANT           0x0800
00045 #define SPAN_LOG_SHOW_TAG               0x1000
00046 
00047 #define SPAN_LOG_SUPPRESS_LABELLING     0x8000
00048 
00049 /* Logging severity levels */
00050 enum
00051 {
00052     SPAN_LOG_NONE                       = 0,
00053     SPAN_LOG_ERROR                      = 1,
00054     SPAN_LOG_WARNING                    = 2,
00055     SPAN_LOG_PROTOCOL_ERROR             = 3,
00056     SPAN_LOG_PROTOCOL_WARNING           = 4,
00057     SPAN_LOG_FLOW                       = 5,
00058     SPAN_LOG_FLOW_2                     = 6,
00059     SPAN_LOG_FLOW_3                     = 7,
00060     SPAN_LOG_DEBUG                      = 8,
00061     SPAN_LOG_DEBUG_2                    = 9,
00062     SPAN_LOG_DEBUG_3                    = 10
00063 };
00064 
00065 /*!
00066     Logging descriptor. This defines the working state for a single instance of
00067     the logging facility for spandsp.
00068 */
00069 typedef struct
00070 {
00071     int level;
00072     const char *tag;
00073     const char *protocol;
00074 } logging_state_t;
00075 
00076 #ifdef __cplusplus
00077 extern "C" {
00078 #endif
00079 
00080 /*! Test if logging of a specified severity level is enabled.
00081     \brief Test if logging of a specified severity level is enabled.
00082     \param s The logging context.
00083     \param level The severity level to be tested.
00084     \return TRUE if logging is enable, else FALSE.
00085 */
00086 int span_log_test(logging_state_t *s, int level);
00087 
00088 /*! Generate a log entry.
00089     \brief Generate a log entry.
00090     \param s The logging context.
00091     \param level The severity level of the entry.
00092     \param format ???
00093     \return 0 if no output generated, else 1.
00094 */
00095 int span_log(logging_state_t *s, int level, const char *format, ...);
00096 
00097 /*! Generate a log entry displaying the contents of a buffer.
00098     \brief Generate a log entry displaying the contents of a buffer
00099     \param s The logging context.
00100     \param level The severity level of the entry.
00101     \param tag A label for the log entry.
00102     \param buf The buffer to be dumped to the log.
00103     \param len The length of buf.
00104     \return 0 if no output generated, else 1.
00105 */
00106 int span_log_buf(logging_state_t *s, int level, const char *tag, const uint8_t *buf, int len);
00107 
00108 int span_log_init(logging_state_t *s, int level, const char *tag);
00109 
00110 int span_log_set_protocol(logging_state_t *s, const char *protocol);
00111 
00112 void span_set_message_handler(void (*func)(int level, const char *text));
00113 
00114 void span_set_error_handler(void (*func)(const char *text));
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00120 #endif
00121 /*- End of file ------------------------------------------------------------*/

Generated on Fri Nov 10 09:40:24 2006 for libspandsp by  doxygen 1.5.1