libUPnP 2.0.1
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
39
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 /* Always the last, please. */
90 UPNP_NEVER
91} Upnp_LogLevel;
93
94/* UPNP_PACKET probably resulted from a confusion between module and
95 level and was only used by a few messages in ssdp_device.c (they
96 have been moved to INFO). Kept for compatibility, don't use for new
97 messages.
98*/
99#define UPNP_PACKET UPNP_ERROR
100
104#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
105
112
113#if defined NDEBUG && !defined UPNP_DEBUG_C
114 #define UpnpInitLog UpnpInitLog_Inlined
115static UPNP_INLINE int UpnpInitLog_Inlined(void) { return UPNP_E_SUCCESS; }
116#endif
122 Upnp_LogLevel log_level);
123
124#if defined NDEBUG && !defined UPNP_DEBUG_C
125 #define UpnpSetLogLevel UpnpSetLogLevel_Inlined
126static UPNP_INLINE void UpnpSetLogLevel_Inlined(Upnp_LogLevel log_level)
127{
128 (void)log_level;
129 return;
130}
131#endif
132
137
138#if defined NDEBUG && !defined UPNP_DEBUG_C
139 #define UpnpCloseLog UpnpCloseLog_Inlined
140static UPNP_INLINE void UpnpCloseLog_Inlined(void) {}
141#endif
142
150 const char *fileName,
152 const char *Ignored);
153
154#if defined NDEBUG && !defined UPNP_DEBUG_C
155 #define UpnpSetLogFileNames UpnpSetLogFileNames_Inlined
156static UPNP_INLINE void UpnpSetLogFileNames_Inlined(
157 const char *ErrFileName, const char *ignored)
158{
159 (void)ErrFileName;
160 (void)ignored;
161 return;
162}
163#endif
164
175 Upnp_LogLevel level,
177 Dbg_Module module);
178
179#if defined NDEBUG && !defined UPNP_DEBUG_C
180 #define UpnpGetDebugFile UpnpGetDebugFile_Inlined
181static UPNP_INLINE FILE *UpnpGetDebugFile_Inlined(
182 Upnp_LogLevel level, Dbg_Module module)
183{
184 (void)level;
185 (void)module;
186 return NULL;
187}
188#endif
189
190/* UpnpPrintf is an internal function removed from the public API (issue #365).
191 * Library-internal callers: include upnpdebug_internal.h.
192 * External callers: use UpnpGetDebugFile() to obtain the log FILE pointer. */
193
194#ifdef __cplusplus
195}
196#endif
197
198#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:101
#define UPNP_INLINE
Declares an inline function.
Definition UpnpGlobal.h:115
#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:115
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:299
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:142
void UpnpCloseLog(void)
Closes the log files.
Definition upnpdebug.c:121
int UpnpInitLog(void)
Initialize the log files.
Definition upnpdebug.c:71