libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Logger Class Reference

This is a singleton class. More...

#include <log.h>

Public Types

enum  LogLevel {
  LLNON =0, LLFAT =1, LLERR =2, LLINF =3,
  LLDEB =4, LLDEB0 =5, LLDEB1 =6, LLDEB2 =7
}
 Log level values. More...
 

Public Member Functions

bool reopen (const std::string &fn)
 Close and reopen the output file. More...
 
std::ostream & getstream ()
 Retrieve the output stream in case you need to write directly to it. More...
 
void setLogLevel (LogLevel level)
 Set the log dynamic verbosity level.
 
void setloglevel (LogLevel level)
 Set the log dynamic verbosity level.
 
int getloglevel () const
 Retrieve the current log level.
 
const std::string & getlogfilename () const
 Retrieve current log file name.
 
bool logisstderr () const
 Logging to stderr ?
 
void logthedate (bool onoff)
 turn date logging on or off (default is off)
 
bool loggingdate () const
 
void setdateformat (const std::string fmt)
 Set the date format, as an strftime() format string. More...
 
const char * datestring ()
 Call with log locked.
 
std::recursive_mutex & getmutex ()
 

Static Public Member Functions

static LoggergetTheLog (const std::string &fn=std::string())
 Initialize logging to file name. More...
 

Detailed Description

This is a singleton class.

The logger pointer is obtained when needed by calls to getTheLog(), only the first of which actually creates the object and initializes the output.

Member Enumeration Documentation

◆ LogLevel

Log level values.

Messages at level above the current will not be printed. Messages at a level above LOGGER_STATICVERBOSITY will not even be compiled in.

Member Function Documentation

◆ getstream()

std::ostream& Logger::getstream ( )
inline

Retrieve the output stream in case you need to write directly to it.

In a multithreaded program, you probably also need to obtain the mutex with getmutex, and lock it.

◆ getTheLog()

Logger * Logger::getTheLog ( const std::string &  fn = std::string())
static

Initialize logging to file name.

Use "stderr" for stderr output. Creates the singleton logger object. Only the first call changes the state, further ones just return the Logger pointer.

◆ reopen()

bool Logger::reopen ( const std::string &  fn)

Close and reopen the output file.

For rotating the log: rename then reopen.

◆ setdateformat()

void Logger::setdateformat ( const std::string  fmt)
inline

Set the date format, as an strftime() format string.

Default: "%Y%m%d-%H%M%S" .


The documentation for this class was generated from the following files: