libUPnP 22.0.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
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
115 /* UPNP_E_SUCCESS is defined in upnp.h; provide fallback if not yet
116 * included */
117 #ifndef UPNP_E_SUCCESS
118 #define UPNP_E_SUCCESS 0
119 #endif
120static UPNP_INLINE int UpnpInitLog_Inlined(void) { return UPNP_E_SUCCESS; }
121#endif
127 Upnp_LogLevel log_level);
128
129#if defined NDEBUG && !defined UPNP_DEBUG_C
130 #define UpnpSetLogLevel UpnpSetLogLevel_Inlined
131static UPNP_INLINE void UpnpSetLogLevel_Inlined(Upnp_LogLevel log_level)
132{
133 (void)log_level;
134 return;
135}
136#endif
137
142
143#if defined NDEBUG && !defined UPNP_DEBUG_C
144 #define UpnpCloseLog UpnpCloseLog_Inlined
145static UPNP_INLINE void UpnpCloseLog_Inlined(void) {}
146#endif
147
155 const char *fileName,
157 const char *Ignored);
158
159#if defined NDEBUG && !defined UPNP_DEBUG_C
160 #define UpnpSetLogFileNames UpnpSetLogFileNames_Inlined
161static UPNP_INLINE void UpnpSetLogFileNames_Inlined(
162 const char *ErrFileName, const char *ignored)
163{
164 (void)ErrFileName;
165 (void)ignored;
166 return;
167}
168#endif
169
180 Upnp_LogLevel level,
182 Dbg_Module module);
183
184#if defined NDEBUG && !defined UPNP_DEBUG_C
185 #define UpnpGetDebugFile UpnpGetDebugFile_Inlined
186static UPNP_INLINE FILE *UpnpGetDebugFile_Inlined(
187 Upnp_LogLevel level, Dbg_Module module)
188{
189 (void)level;
190 (void)module;
191 return NULL;
192}
193#endif
194
195/* UpnpPrintf is an internal function removed from the public API (issue #365).
196 * Library-internal callers: include upnpdebug_internal.h.
197 * External callers: use UpnpGetDebugFile() to obtain the log FILE pointer. */
198
199#ifdef __cplusplus
200}
201#endif
202
203#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:116
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:300
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:143
void UpnpCloseLog(void)
Closes the log files.
Definition upnpdebug.c:122
int UpnpInitLog(void)
Initialize the log files.
Definition upnpdebug.c:72