00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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"
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
00225 __attribute__((format (__printf__, 5, 6)))
00226 #endif
00227 ;
00228 #else
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
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
00314