libUPnP 1.14.19
upnpdebug.h
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * Copyright (c) 2006 Rémi Turboult <r3mi@users.sourceforge.net>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * - Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * - Neither name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32
33#ifndef UPNP_DEBUG_H
34#define UPNP_DEBUG_H
35
40#include "UpnpGlobal.h" /* for UPNP_INLINE */
41#include "upnpconfig.h"
42
43#include <stdio.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
54
70typedef enum Upnp_Module
71{
72 SSDP,
73 SOAP,
74 GENA,
75 TPOOL,
76 MSERV,
77 DOM,
78 API,
79 HTTP
80} Dbg_Module;
81
83typedef enum Upnp_LogLevel_e
84{
85 UPNP_CRITICAL,
86 UPNP_ERROR,
87 UPNP_INFO,
88 UPNP_ALL
89} Upnp_LogLevel;
92/* UPNP_PACKET probably resulted from a confusion between module and
93 level and was only used by a few messages in ssdp_device.c (they
94 have been moved to INFO). Kept for compatibility, don't use for new
95 messages.
96*/
97#define UPNP_PACKET UPNP_ERROR
98
102#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
103
110
111#if defined NDEBUG && !defined UPNP_DEBUG_C
112 #define UpnpInitLog UpnpInitLog_Inlined
113static UPNP_INLINE int UpnpInitLog_Inlined(void) { return UPNP_E_SUCCESS; }
114#endif
120 Upnp_LogLevel log_level);
121
122#if defined NDEBUG && !defined UPNP_DEBUG_C
123 #define UpnpSetLogLevel UpnpSetLogLevel_Inlined
124static UPNP_INLINE void UpnpSetLogLevel_Inlined(Upnp_LogLevel log_level)
125{
126 (void)log_level;
127 return;
128}
129#endif
130
134void UpnpCloseLog(void);
135
136#if defined NDEBUG && !defined UPNP_DEBUG_C
137 #define UpnpCloseLog UpnpCloseLog_Inlined
138static UPNP_INLINE void UpnpCloseLog_Inlined(void) {}
139#endif
140
148 const char *fileName,
150 const char *Ignored);
151
152#if defined NDEBUG && !defined UPNP_DEBUG_C
153 #define UpnpSetLogFileNames UpnpSetLogFileNames_Inlined
154static UPNP_INLINE void UpnpSetLogFileNames_Inlined(
155 const char *ErrFileName, const char *ignored)
156{
157 (void)ErrFileName;
158 (void)ignored;
159 return;
160}
161#endif
162
170FILE *UpnpGetDebugFile(
173 Upnp_LogLevel level,
175 Dbg_Module module);
176
177#if defined NDEBUG && !defined UPNP_DEBUG_C
178 #define UpnpGetDebugFile UpnpGetDebugFile_Inlined
179static UPNP_INLINE FILE *UpnpGetDebugFile_Inlined(
180 Upnp_LogLevel level, Dbg_Module module)
181{
182 (void)level;
183 (void)module;
184 return NULL;
185}
186#endif
187
192void UpnpPrintf(
195 Upnp_LogLevel DLevel,
197 Dbg_Module Module,
199 const char *DbgFileName,
202 int DbgLineNo,
204 const char *FmtStr,
207 ...)
208#if (__GNUC__ >= 3)
209 /* This enables printf like format checking by the compiler. */
210 __attribute__((format(__printf__, 5, 6)))
211#endif
212 ;
213
214#if defined NDEBUG && !defined UPNP_DEBUG_C
215 #define UpnpPrintf UpnpPrintf_Inlined
216// static UPNP_INLINE void UpnpPrintf_Inlined(Upnp_LogLevel DLevel,
217// Dbg_Module Module,
218// const char *DbgFileName,
219// int DbgLineNo,
220// const char *FmtStr,
221// ...)
222// #if (__GNUC__ >= 3)
223// /* This enables printf like format checking by the compiler. */
224// __attribute__((format(__printf__, 5, 6)))
225// #endif
226// ;
227static UPNP_INLINE void UpnpPrintf_Inlined(Upnp_LogLevel DLevel,
228 Dbg_Module Module,
229 const char *DbgFileName,
230 int DbgLineNo,
231 const char *FmtStr,
232 ...)
233{
234 (void)DLevel;
235 (void)Module;
236 (void)DbgFileName;
237 (void)DbgLineNo;
238 (void)FmtStr;
239 return;
240}
241#endif /* DEBUG */
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif /* UPNP_DEBUG_H */
Defines constants that for some reason are not defined on some systems.
#define UPNP_EXPORT_SPEC
Export functions on WIN32 DLLs.
Definition UpnpGlobal.h:98
#define UPNP_INLINE
Declares an inline function.
Definition UpnpGlobal.h:112
#define UPNP_E_SUCCESS
The operation completed successfully.
Definition upnp.h:97
void UpnpSetLogLevel(Upnp_LogLevel log_level)
Set the log level (see Upnp_LogLevel).
Definition upnpdebug.c:114
FILE * UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
Check if the module is turned on for debug and returns the file descriptor corresponding to the debug...
Definition upnpdebug.c:295
void UpnpSetLogFileNames(const char *fileName, const char *Ignored)
Set the name for the log file. There used to be 2 separate files. The second parameter has been kept ...
Definition upnpdebug.c:141
void UpnpCloseLog(void)
Closes the log files.
Definition upnpdebug.c:120
int UpnpInitLog(void)
Initialize the log files.
Definition upnpdebug.c:71
void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement either on the standard output or log file along with the information from ...
Definition upnpdebug.c:259