44#include <umock/pthread.hpp>
45#include <umock/stdio.hpp>
78 TRACE(
"Executing UpnpInitLog()")
80 umock::pthread_h.pthread_mutex_init(&
debug_mutex,
nullptr);
89 umock::stdio_h.fclose(
filed);
95 if (
filed ==
nullptr) {
97 "UPnPlib Error: failed to open filename \"%s\": %s. "
98 "Fallback to stderr.\n",
104 if (
filed ==
nullptr)
111 TRACE(
"Executing UpnpSetLogLevel()")
117 TRACE(
"Executing UpnpCloseLog()")
126 umock::stdio_h.fclose(
filed);
133 umock::pthread_h.pthread_mutex_unlock(&
debug_mutex);
134 umock::pthread_h.pthread_mutex_destroy(&
debug_mutex);
139 [[maybe_unused]]
const char* ignored) {
140 TRACE(
"Executing UpnpSetLogFileNames()")
146 if (newFileName && *newFileName !=
'\0') {
167 time_t now = time(NULL);
174 case UPNP_CRITICAL: slev=
"CRI";
break;
175 case UPNP_ERROR: slev=
"ERR";
break;
176 case UPNP_INFO: slev=
"INF";
break;
177 case UPNP_ALL: slev=
"ALL";
break;
178 default: slev=
"UNK";
break;
182 snprintf(slev, 25,
"%d", DLevel);
216 struct tm timeinfo = {.tm_sec = 0,
225 localtime_s(&timeinfo, &now);
226 strftime(timebuf, 26,
"%Y-%m-%d %H:%M:%S", &timeinfo);
229 timeinfo = localtime(&now);
230 strftime(timebuf, 26,
"%Y-%m-%d %H:%M:%S", timeinfo);
233 fprintf(a_fp,
"%s UPNP-%s-%s: Thread:0x%llX [%s:%d]: ", timebuf, smod, slev,
234#ifdef __PTW32_DLLPORT
235 *(
unsigned long long int*)pthread_self().p
237 (
unsigned long long int)pthread_self()
240 DbgFileName, DbgLineNo);
245 const char* DbgFileName,
int DbgLineNo,
const char* FmtStr,
258 if (
filed ==
nullptr) {
259 umock::pthread_h.pthread_mutex_unlock(&
debug_mutex);
263 va_start(ArgList, FmtStr);
268 DbgLineNo, DLevel, Module);
269 vfprintf(
filed, FmtStr, ArgList);
274 umock::pthread_h.pthread_mutex_unlock(&
debug_mutex);
Main program configuration file.
#define DEBUG_ALL
Debug feature.
#define DEBUG_MSERV
Debug feature.
#define DEBUG_GENA
Debug feature.
#define DEBUG_TPOOL
Debug feature.
#define DEBUG_SOAP
Debug feature.
#define DEBUG_SSDP
Debug feature.
#define DEBUG_HTTP
Debug feature.
#define DEBUG_DOM
Debug feature.
#define UPNP_E_SUCCESS
The operation completed successfully.
pthread_mutex_t debug_mutex
Define macro for synced logging to the console for detailed info and debug.
void UpnpSetLogLevel(Upnp_LogLevel log_level)
Set the log level (see Upnp_LogLevel).
static Upnp_LogLevel g_log_level
static void UpnpDisplayFileAndLine(FILE *a_fp, const char *DbgFileName, int DbgLineNo, Upnp_LogLevel DLevel, Dbg_Module Module)
Display File and Line.
void UpnpSetLogFileNames(const char *newFileName, const char *ignored)
Set the name for the log file. There used to be 2 separate files. The second parameter has been kept ...
FILE * UpnpGetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
Check if the module is turned on for debug and returns the file descriptor corresponding to the debug...
int UpnpInitLog()
Initialize the log files.
static int DebugAtThisLevel(Upnp_LogLevel DLevel, Dbg_Module Module)
Check Debug level.
static int setlogwascalled
void UpnpCloseLog()
Closes the log files.
void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement.
Manage Debug messages with levels "critical" to "all".
enum Upnp_Module Dbg_Module
Only debug messages from this program module.
#define UPNP_DEFAULT_LOG_LEVEL
enum Upnp_LogLevel_e Upnp_LogLevel
Upnp_LogLevel.