libUPnP 1.8.4
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 "upnpconfig.h"
41#include "UpnpGlobal.h" /* for UPNP_INLINE */
42
43#include <stdio.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
54
71typedef enum Upnp_Module {
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 UPNP_CRITICAL,
85 UPNP_PACKET,
86 UPNP_INFO,
87 UPNP_ALL
88} Upnp_LogLevel;
94#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
95
101#ifdef DEBUG
102int UpnpInitLog(void);
103#else
104static UPNP_INLINE int UpnpInitLog(void)
105{
106 return UPNP_E_SUCCESS;
107}
108#endif
112#ifdef DEBUG
113void UpnpSetLogLevel(
115 Upnp_LogLevel log_level);
116#else
117static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level)
118{
119 return;
120 log_level = log_level;
121}
122#endif
123
127#ifdef DEBUG
128void UpnpCloseLog(void);
129#else
130static UPNP_INLINE void UpnpCloseLog(void)
131{
132}
133#endif
134
138#ifdef DEBUG
141 const char *ErrFileName,
143 const char *InfoFileName);
144#else
145static UPNP_INLINE void UpnpSetLogFileNames(const char *ErrFileName,
146 const char *InfoFileName)
147{
148 return;
149 ErrFileName = ErrFileName;
150 InfoFileName = InfoFileName;
151}
152#endif
153
161#ifdef DEBUG
165 Upnp_LogLevel level,
167 Dbg_Module module);
168#else
169static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
170{
171 return NULL;
172 level = level;
173 module = module;
174}
175#endif
176
182#ifdef DEBUG
186 Upnp_LogLevel DLevel,
188 Dbg_Module Module);
189#else
190static UPNP_INLINE int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
191{
192 return 0;
193 DLevel = DLevel;
194 Module = Module;
195}
196#endif
197
202#ifdef DEBUG
203void UpnpPrintf(
206 Upnp_LogLevel DLevel,
208 Dbg_Module Module,
210 const char *DbgFileName,
212 int DbgLineNo,
214 const char *FmtStr,
217 ...)
218#if (__GNUC__ >= 3)
219 /* This enables printf like format checking by the compiler. */
220 __attribute__ ((format(__printf__, 5, 6)))
221#endif
222 ;
223#else /* DEBUG */
224static UPNP_INLINE void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module,
225 const char *DbgFileName, int DbgLineNo, const char *FmtStr, ...)
226{
227 return;
228 DLevel = DLevel;
229 Module = Module;
230 DbgFileName = DbgFileName;
231 DbgLineNo = DbgLineNo;
232 FmtStr = FmtStr;
233}
234#endif /* DEBUG */
235
240#ifdef DEBUG
244 FILE * fd,
246 const char *DbgFileName,
248 int DbgLineNo);
249#else
250static UPNP_INLINE void UpnpDisplayFileAndLine(FILE *fd,
251 const char *DbgFileName, int DbgLineNo)
252{
253 return;
254 fd = fd;
255 DbgFileName = DbgFileName;
256 DbgLineNo = DbgLineNo;
257}
258#endif
259
263#ifdef DEBUG
266 FILE * fd,
268 const char **lines,
270 size_t size,
272 size_t starlength);
273#else
274static UPNP_INLINE void UpnpDisplayBanner(FILE *fd, const char **lines,
275 size_t size, int starlength)
276{
277 return;
278 fd = fd;
279 lines = lines;
280 size = size;
281 starlength = starlength;
282}
283#endif
284
287#ifdef __cplusplus
288}
289#endif
290
291#endif /* UPNP_DEBUG_H */
Defines constants that for some reason are not defined on some systems.
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:99
#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:85
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...
void UpnpSetLogFileNames(const char *ErrFileName, const char *InfoFileName)
Set the name for error and information files, respectively.
Definition: upnpdebug.c:101
int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
Returns true if debug output should be done in this module.
Definition: upnpdebug.c:111
void UpnpCloseLog(void)
Closes the log files.
Definition: upnpdebug.c:90
void UpnpDisplayFileAndLine(FILE *fd, const char *DbgFileName, int DbgLineNo)
Writes the file name and file number from where debug statement is coming to the log file.
Definition: upnpdebug.c:176
int UpnpInitLog(void)
Initialize the log files.
Definition: upnpdebug.c:69
void UpnpDisplayBanner(FILE *fd, const char **lines, size_t size, size_t starlength)
Writes the buffer in the file as per the requested banner.
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:127