UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
upnpdebug.cpp File Reference

Manage Debug messages with levels "critical" to "all". More...

#include <config.hpp>
#include <upnpdebug.hpp>
#include <UPnPsdk/synclog.hpp>
#include <umock/pthread.hpp>
#include <umock/stdio.hpp>
+ Include dependency graph for upnpdebug.cpp:

Go to the source code of this file.

Functions

int UpnpInitLog ()
 Initialize the log files.
 
void UpnpSetLogLevel (Upnp_LogLevel log_level)
 Set the log level (see Upnp_LogLevel).
 
void UpnpCloseLog ()
 Closes the log files.
 
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 for compatibility but is ignored. Use a NULL file name for logging to stderr.
 
static int DebugAtThisLevel (Upnp_LogLevel DLevel, Dbg_Module Module)
 Check Debug level.
 
static void UpnpDisplayFileAndLine (FILE *a_fp, const char *DbgFileName, int DbgLineNo, Upnp_LogLevel DLevel, Dbg_Module Module)
 Display File and Line.
 
void UpnpPrintf (Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
 Prints the debug statement.
 
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 level. .
 

Variables

pthread_mutex_t anonymous_namespace{upnpdebug.cpp}::debug_mutex
 
static Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL
 
static FILE * filed
 
static int setlogwascalled
 
static int initwascalled
 
static char * fileName
 

Detailed Description

Manage Debug messages with levels "critical" to "all".

Definition in file upnpdebug.cpp.

Macro Definition Documentation

◆ UPNP_DEBUG_C

#define UPNP_DEBUG_C

Definition at line 38 of file upnpdebug.cpp.

Function Documentation

◆ UpnpInitLog()

int UpnpInitLog ( void  )

Initialize the log files.

Returns
-1 if fails or UPNP_E_SUCCESS if succeeds.

Definition at line 77 of file upnpdebug.cpp.

+ Here is the caller graph for this function:

◆ UpnpSetLogLevel()

void UpnpSetLogLevel ( Upnp_LogLevel  log_level)

Set the log level (see Upnp_LogLevel).

Parameters
[in]log_levelLog level.

Definition at line 110 of file upnpdebug.cpp.

◆ UpnpCloseLog()

void UpnpCloseLog ( void  )

Closes the log files.

Definition at line 116 of file upnpdebug.cpp.

+ Here is the caller graph for this function:

◆ UpnpSetLogFileNames()

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 for compatibility but is ignored. Use a NULL file name for logging to stderr.

Parameters
[in]newFileNameName of the log file.
[in]ignoredIgnored.

Definition at line 138 of file upnpdebug.cpp.

◆ DebugAtThisLevel()

static int DebugAtThisLevel ( Upnp_LogLevel  DLevel,
Dbg_Module  Module 
)
static

Check Debug level.

Definition at line 153 of file upnpdebug.cpp.

+ Here is the caller graph for this function:

◆ UpnpDisplayFileAndLine()

static void UpnpDisplayFileAndLine ( FILE *  a_fp,
const char *  DbgFileName,
int  DbgLineNo,
Upnp_LogLevel  DLevel,
Dbg_Module  Module 
)
static

Display File and Line.

Definition at line 163 of file upnpdebug.cpp.

+ Here is the caller graph for this function:

◆ UpnpPrintf()

void UpnpPrintf ( Upnp_LogLevel  DLevel,
Dbg_Module  Module,
const char *  DbgFileName,
int  DbgLineNo,
const char *  FmtStr,
  ... 
)

Prints the debug statement.

Prints either on the standard output or log file along with the information from where this debug statement is coming.

Parameters
[in]DLevelThe level of the debug logging. It will decide whether debug statement will go to standard output, or any of the log files.
[in]Moduledebug will go in the name of this module.
[in]DbgFileNameName of the file from where debug statement is coming.
[in]DbgLineNoLine number of the file from where debug statement is coming.
[in]FmtStrPrintf like format specification.
[in]...Printf like Variable number of arguments that will go in the debug statement.

Definition at line 244 of file upnpdebug.cpp.

+ Here is the call graph for this function:

◆ UpnpGetDebugFile()

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 level. .

Returns
nullptr if the module is turn off for debug otherwise returns the right FILE pointer.
Parameters
[in]DLevelThe level of the debug logging. It will decide whether debug statement will go to standard output, or any of the log files.
[in]Moduledebug will go in the name of this module.

Definition at line 279 of file upnpdebug.cpp.

+ Here is the call graph for this function:

Variable Documentation

◆ g_log_level

Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL
static

Global log level

Definition at line 61 of file upnpdebug.cpp.

◆ filed

FILE* filed
static

Output file descriptor

Definition at line 64 of file upnpdebug.cpp.

◆ setlogwascalled

int setlogwascalled
static

Set if the user called setlogfilename() or setloglevel()

Definition at line 67 of file upnpdebug.cpp.

◆ initwascalled

int initwascalled
static

The UPnP Debug module is initialized

Definition at line 69 of file upnpdebug.cpp.

◆ fileName

char* fileName
static

Name of the output file. We keep a copy

Definition at line 71 of file upnpdebug.cpp.