Liblinphone  5.2.0
Public Member Functions | Static Public Member Functions | List of all members
linphone::LoggingService Class Reference

Singleton class giving access to logging features. More...

#include <logging_service.hh>

Inheritance diagram for linphone::LoggingService:

Public Member Functions

 LoggingService (void *ptr, bool takeRef=true)
 
LINPHONECXX_PUBLIC _LinphoneLoggingService * cPtr ()
 
LINPHONECXX_PUBLIC void addListener (const std::shared_ptr< LoggingServiceListener > &listener)
 
LINPHONECXX_PUBLIC void removeListener (const std::shared_ptr< LoggingServiceListener > &listener)
 
LINPHONECXX_PUBLIC std::string getDomain ()
 Get the domain where application logs are written (for example with message()). More...
 
LINPHONECXX_PUBLIC void setDomain (const std::string &domain)
 Set the domain where application logs are written (for example with message()). More...
 
LINPHONECXX_PUBLIC void setLogLevel (linphone::LogLevel level)
 Set the verbosity of the log. More...
 
LINPHONECXX_PUBLIC unsigned int getLogLevelMask () const
 Gets the log level mask. More...
 
LINPHONECXX_PUBLIC void setLogLevelMask (unsigned int mask)
 Sets the types of messages that will be authorized to be written in the log. More...
 
LINPHONECXX_PUBLIC void debug (const std::string &message)
 Write a LinphoneLogLevelDebug message to the logs. More...
 
LINPHONECXX_PUBLIC void error (const std::string &message)
 Write a LinphoneLogLevelError message to the logs. More...
 
LINPHONECXX_PUBLIC void fatal (const std::string &message)
 Write a LinphoneLogLevelFatal message to the logs. More...
 
LINPHONECXX_PUBLIC void message (const std::string &message)
 Write a LinphoneLogLevelMessage message to the logs. More...
 
LINPHONECXX_PUBLIC void setLogFile (const std::string &dir, const std::string &filename, size_t maxSize) const
 Enables logging in a file. More...
 
LINPHONECXX_PUBLIC void trace (const std::string &message)
 Write a LinphoneLogLevelTrace message to the logs. More...
 
LINPHONECXX_PUBLIC void warning (const std::string &message)
 Write a LinphoneLogLevelWarning message to the logs. More...
 

Static Public Member Functions

static LINPHONECXX_PUBLIC std::shared_ptr< linphone::LoggingServiceget ()
 Gets the singleton logging service object. More...
 

Detailed Description

Singleton class giving access to logging features.

It supports custom domain, writing into a file as well as several verbosity levels. The LinphoneLoggingServiceCbs listener allows you to be notified each time a log is printed. As the LoggingService is a singleton, use get() to get it.

Member Function Documentation

◆ debug()

LINPHONECXX_PUBLIC void linphone::LoggingService::debug ( const std::string &  message)

Write a LinphoneLogLevelDebug message to the logs.

Parameters
messageThe log message.

◆ error()

LINPHONECXX_PUBLIC void linphone::LoggingService::error ( const std::string &  message)

Write a LinphoneLogLevelError message to the logs.

Parameters
messageThe log message.

◆ fatal()

LINPHONECXX_PUBLIC void linphone::LoggingService::fatal ( const std::string &  message)

Write a LinphoneLogLevelFatal message to the logs.

Parameters
messageThe log message.

◆ get()

static LINPHONECXX_PUBLIC std::shared_ptr<linphone::LoggingService> linphone::LoggingService::get ( )
static

Gets the singleton logging service object.

The singleton is automatically instantiated if it hasn't been done yet.

Returns
A pointer on the LoggingService singleton.

◆ getDomain()

LINPHONECXX_PUBLIC std::string linphone::LoggingService::getDomain ( )

Get the domain where application logs are written (for example with message()).

Returns
The domain where application logs are written.

◆ getLogLevelMask()

LINPHONECXX_PUBLIC unsigned int linphone::LoggingService::getLogLevelMask ( ) const

Gets the log level mask.

Returns
the log level mask

◆ message()

LINPHONECXX_PUBLIC void linphone::LoggingService::message ( const std::string &  message)

Write a LinphoneLogLevelMessage message to the logs.

Parameters
messageThe log message.

◆ setDomain()

LINPHONECXX_PUBLIC void linphone::LoggingService::setDomain ( const std::string &  domain)

Set the domain where application logs are written (for example with message()).

Parameters
domainThe domain.
Note
The domain is mandatory to write logs. This needs to be set before setting the log level.

◆ setLogFile()

LINPHONECXX_PUBLIC void linphone::LoggingService::setLogFile ( const std::string &  dir,
const std::string &  filename,
size_t  maxSize 
) const

Enables logging in a file.

That function enables an internal log handler that writes log messages in log-rotated files.

Parameters
maxSizeThe maximal size of each part of the log. The log rotating is triggered each time the currently opened log part reach that limit.

◆ setLogLevel()

LINPHONECXX_PUBLIC void linphone::LoggingService::setLogLevel ( linphone::LogLevel  level)

Set the verbosity of the log.

For instance, a level of LogLevel::Message will let pass fatal, error, warning and message-typed messages whereas trace and debug messages will be dumped out.

Parameters
levelthe LogLevel to set

◆ setLogLevelMask()

LINPHONECXX_PUBLIC void linphone::LoggingService::setLogLevelMask ( unsigned int  mask)

Sets the types of messages that will be authorized to be written in the log.

Parameters
maskExample: LogLevel::Message|LogLevel::Error will ONLY let pass message-typed and error messages.
Note
Calling that function reset the log level that has been specified by setLogLevel().

◆ trace()

LINPHONECXX_PUBLIC void linphone::LoggingService::trace ( const std::string &  message)

Write a LinphoneLogLevelTrace message to the logs.

Parameters
messageThe log message.

◆ warning()

LINPHONECXX_PUBLIC void linphone::LoggingService::warning ( const std::string &  message)

Write a LinphoneLogLevelWarning message to the logs.

Parameters
messageThe log message.

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