libUPnP  1.6.20
Functions | Variables
upnpdebug.c File Reference
#include "config.h"
#include "ithread.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include <libgen.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for upnpdebug.c:

Functions

int UpnpInitLog (void)
 Initialize the log files. More...
 
void UpnpSetLogLevel (Upnp_LogLevel log_level)
 Set the log level (see Upnp_LogLevel). More...
 
void UpnpCloseLog (void)
 Closes the log files. More...
 
void UpnpSetLogFileNames (const char *ErrFileName, const char *InfoFileName)
 Set the name for error and information files, respectively. More...
 
int DebugAtThisLevel (Upnp_LogLevel DLevel, Dbg_Module Module)
 Returns true if debug output should be done in this module. More...
 
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 where this debug statement is coming. More...
 
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. More...
 
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. More...
 

Variables

static ithread_mutex_t GlobalDebugMutex
 
static Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL
 
static FILE * ErrFileHnd = NULL
 
static FILE * InfoFileHnd = NULL
 
static const char * errFileName = NULL
 
static const char * infoFileName = NULL
 

Function Documentation

◆ DebugAtThisLevel()

int DebugAtThisLevel ( Upnp_LogLevel  DLevel,
Dbg_Module  Module 
)

Returns true if debug output should be done in this module.

Returns
Nonzero value if true, zero if false.
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.

References g_log_level.

Referenced by UpnpGetDebugFile(), and UpnpPrintf().

◆ UpnpCloseLog()

void UpnpCloseLog ( void  )

Closes the log files.

References ErrFileHnd, and InfoFileHnd.

◆ UpnpDisplayFileAndLine()

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.

Parameters
[in]fdFile descriptor where line number and file name will be written.
[in]DbgFileNameName of the file.
[in]DbgLineNoLine number of the file.

◆ UpnpGetDebugFile()

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

Returns
NULL if the module is turn off for debug otheriwse returns the right file descriptor.
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.

References DebugAtThisLevel().

◆ UpnpInitLog()

int UpnpInitLog ( void  )

Initialize the log files.

Returns
-1 if fails or UPNP_E_SUCCESS if succeeds.

Referenced by UpnpInitPreamble().

◆ UpnpPrintf()

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

References DebugAtThisLevel().

Referenced by FreeHandle(), gena_process_subscription_request(), get_port(), getlocalhostname(), handle_query_variable(), notify_send_and_recv(), printService(), printServiceList(), printServiceTable(), PrintThreadPoolStats(), UpnpAcceptSubscription(), UpnpAcceptSubscriptionExt(), UpnpFinish(), UpnpGetIfInfo(), UpnpGetServiceVarStatus(), UpnpGetServiceVarStatusAsync(), UpnpInitPreamble(), UpnpInitStartServers(), UpnpNotify(), UpnpNotifyExt(), UpnpRegisterClient(), UpnpRegisterRootDevice3(), UpnpRenewSubscription(), UpnpRenewSubscriptionAsync(), UpnpSearchAsync(), UpnpSendAction(), UpnpSendActionAsync(), UpnpSendActionEx(), UpnpSendActionExAsync(), UpnpSendAdvertisement(), UpnpSendAdvertisementLowPower(), UpnpSetMaxSubscriptions(), UpnpSetMaxSubscriptionTimeOut(), UpnpSubscribe(), UpnpSubscribeAsync(), UpnpThreadDistribution(), UpnpUnRegisterClient(), UpnpUnRegisterRootDevice(), UpnpUnRegisterRootDeviceLowPower(), UpnpUnSubscribe(), and UpnpUnSubscribeAsync().

◆ UpnpSetLogFileNames()

void UpnpSetLogFileNames ( const char *  ErrFileName,
const char *  InfoFileName 
)

Set the name for error and information files, respectively.

Parameters
[in]ErrFileNameName of the error file.
[in]InfoFileNameName of the information file.

References errFileName, and infoFileName.

◆ UpnpSetLogLevel()

void UpnpSetLogLevel ( Upnp_LogLevel  log_level)

Set the log level (see Upnp_LogLevel).

Parameters
[in]log_levelLog level.

References g_log_level.

Variable Documentation

◆ ErrFileHnd

FILE* ErrFileHnd = NULL
static

File handle for the error log file

Referenced by UpnpCloseLog().

◆ errFileName

const char* errFileName = NULL
static

Name of the error file

Referenced by UpnpSetLogFileNames().

◆ g_log_level

Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL
static

Global log level

Referenced by DebugAtThisLevel(), and UpnpSetLogLevel().

◆ GlobalDebugMutex

ithread_mutex_t GlobalDebugMutex
static

Mutex to synchronize all the log file opeartions in the debug mode

◆ InfoFileHnd

FILE* InfoFileHnd = NULL
static

File handle for the information log file

Referenced by UpnpCloseLog().

◆ infoFileName

const char* infoFileName = NULL
static

Name of the info file

Referenced by UpnpSetLogFileNames().