libUPnP 1.8.0
upnpdebug.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2000-2003 Intel Corporation 
00004  * Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
00005  * All rights reserved. 
00006  *
00007  * Redistribution and use in source and binary forms, with or without 
00008  * modification, are permitted provided that the following conditions are met: 
00009  *
00010  * - Redistributions of source code must retain the above copyright notice, 
00011  * this list of conditions and the following disclaimer. 
00012  * - Redistributions in binary form must reproduce the above copyright notice, 
00013  * this list of conditions and the following disclaimer in the documentation 
00014  * and/or other materials provided with the distribution. 
00015  * - Neither name of Intel Corporation nor the names of its contributors 
00016  * may be used to endorse or promote products derived from this software 
00017  * without specific prior written permission.
00018  * 
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
00027  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  ******************************************************************************/
00032 
00033 #ifndef UPNP_DEBUG_H
00034 #define UPNP_DEBUG_H 
00035 
00036 
00042 #include "ThreadPool.h"
00043 #include "upnpconfig.h"
00044 #include "UpnpGlobal.h" /* for UPNP_INLINE */
00045 
00046 
00047 #include <stdio.h>
00048 
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 
00054 
00060 
00077 typedef enum Upnp_Module {
00078         SSDP,
00079         SOAP,
00080         GENA,
00081         TPOOL,
00082         MSERV,
00083         DOM,
00084         API,
00085         HTTP
00086 } Dbg_Module;
00087 
00088 
00090 typedef enum Upnp_LogLevel_e {
00091         UPNP_CRITICAL,
00092         UPNP_PACKET,
00093         UPNP_INFO,
00094         UPNP_ALL
00095 } Upnp_LogLevel;
00102 #define UPNP_DEFAULT_LOG_LEVEL  UPNP_ALL
00103 
00104 
00105 
00111 #ifdef DEBUG
00112 int UpnpInitLog(void);
00113 #else
00114 static UPNP_INLINE int UpnpInitLog(void)
00115 {
00116         return UPNP_E_SUCCESS;
00117 }
00118 #endif
00119 
00120 
00124 #ifdef DEBUG
00125 void UpnpSetLogLevel(
00127         Upnp_LogLevel log_level);
00128 #else
00129 static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
00130 #endif
00131 
00132 
00136 #ifdef DEBUG
00137 void UpnpCloseLog(void);
00138 #else
00139 static UPNP_INLINE void UpnpCloseLog(void) {}
00140 #endif
00141 
00142 
00146 #ifdef DEBUG
00147 void UpnpSetLogFileNames(
00149         const char *ErrFileName,
00151         const char *InfoFileName);
00152 #else
00153 static UPNP_INLINE void UpnpSetLogFileNames(
00154         const char *ErrFileName,
00155         const char *InfoFileName) {}
00156 #endif
00157 
00158 
00166 #ifdef DEBUG
00167 FILE *UpnpGetDebugFile(
00170         Upnp_LogLevel level,
00172         Dbg_Module module);
00173 #else
00174 static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
00175 {
00176         return NULL;
00177 }
00178 #endif
00179 
00180 
00186 #ifdef DEBUG
00187 int DebugAtThisLevel(
00190         Upnp_LogLevel DLevel,
00192         Dbg_Module Module);
00193 #else
00194 static UPNP_INLINE int DebugAtThisLevel(
00195         Upnp_LogLevel DLevel,
00196         Dbg_Module Module)
00197 {
00198         return 0;
00199 }
00200 #endif
00201 
00202 
00207 #ifdef DEBUG
00208 void UpnpPrintf(
00211         Upnp_LogLevel DLevel,
00213         Dbg_Module Module,
00215         const char* DbgFileName,
00217         int DbgLineNo,
00219         const char* FmtStr,
00222         ...)
00223 #if (__GNUC__ >= 3)
00224         /* This enables printf like format checking by the compiler */
00225         __attribute__((format (__printf__, 5, 6)))
00226 #endif
00227 ;
00228 #else /* DEBUG */
00229 static UPNP_INLINE void UpnpPrintf(
00230         Upnp_LogLevel DLevel,
00231         Dbg_Module Module,
00232         const char* DbgFileName,
00233         int DbgLineNo,
00234         const char* FmtStr,
00235         ...)
00236 {
00237 }
00238 #endif /* DEBUG */
00239 
00240 
00245 #ifdef DEBUG
00246 void UpnpDisplayFileAndLine(
00248         FILE *fd,
00250         const char *DbgFileName,
00252         int DbgLineNo);
00253 #else
00254 static UPNP_INLINE void UpnpDisplayFileAndLine(
00255         FILE *fd,
00256         const char *DbgFileName,
00257         int DbgLineNo) {}
00258 #endif
00259 
00260 
00264 #ifdef DEBUG
00265 void UpnpDisplayBanner(
00267         FILE *fd,
00269         const char **lines,
00271         size_t size,
00273         int starlength);
00274 #else
00275 static UPNP_INLINE void UpnpDisplayBanner(
00276         FILE *fd,
00277         const char **lines,
00278         size_t size,
00279         int starlength) {}
00280 #endif
00281 
00282 
00286 #ifdef DEBUG
00287 void PrintThreadPoolStats(
00289         ThreadPool *tp, 
00291         const char *DbgFileName,
00293         int DbgLineNo,
00295         const char *msg);
00296 #else
00297 static UPNP_INLINE void PrintThreadPoolStats(
00298         ThreadPool *tp, 
00299         const char *DbgFileName,
00300         int DbgLineNo,
00301         const char *msg)
00302 {
00303 }
00304 #endif
00305 
00306 
00309 #ifdef __cplusplus
00310 }
00311 #endif
00312 
00313 #endif /* UPNP_DEBUG_H */
00314