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
LINPHONECXX_PUBLIC | LoggingService (void *ptr, bool takeRef=true)
LINPHONECXX_PUBLIC _LinphoneLoggingService * | cPtr ()
LINPHONECXX_PUBLIC void | addListener (const std::shared_ptr< LoggingServiceListener > &listener)
| Add an application listener to the LoggingService instance.
LINPHONECXX_PUBLIC void | removeListener (const std::shared_ptr< LoggingServiceListener > &listener)
| Remove a previously added listener from the LoggingService instance.
LINPHONECXX_PUBLIC std::string | getDomain ()
| Get the domain where application logs are written (for example with message()).
LINPHONECXX_PUBLIC void | setDomain (const std::string &domain)
| Set the domain where application logs are written (for example with message()).
LINPHONECXX_PUBLIC void | setLogLevel (linphone::LogLevel level)
| Set the verbosity of the log.
LINPHONECXX_PUBLIC unsigned int | getLogLevelMask () const
| Gets the log level mask.
LINPHONECXX_PUBLIC void | setLogLevelMask (unsigned int mask)
| Sets the types of messages that will be authorized to be written in the log.
LINPHONECXX_PUBLIC void | enableStackTraceDumps (bool enable)
| Allow Linphone to set handlers for catching exceptions and write the stack trace into log.
LINPHONECXX_PUBLIC void | debug (const std::string &message)
| Write a LinphoneLogLevelDebug message to the logs.
LINPHONECXX_PUBLIC void | error (const std::string &message)
| Write a LinphoneLogLevelError message to the logs.
LINPHONECXX_PUBLIC void | fatal (const std::string &message)
| Write a LinphoneLogLevelFatal message to the logs.
LINPHONECXX_PUBLIC void | message (const std::string &message)
| Write a LinphoneLogLevelMessage message to the logs.
LINPHONECXX_PUBLIC void | setLogFile (const std::string &dir, const std::string &filename, size_t maxSize) const
| Enables logging in a file.
LINPHONECXX_PUBLIC void | trace (const std::string &message)
| Write a LinphoneLogLevelTrace message to the logs.
LINPHONECXX_PUBLIC void | warning (const std::string &message)
| Write a LinphoneLogLevelWarning message to the logs.

## Static Public Member Functions
static LINPHONECXX_PUBLIC std::shared_ptr< linphone::LoggingService > | get ()
| Gets the singleton logging service object.

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

## ◆ addListener()

LINPHONECXX_PUBLIC void linphone::LoggingService::addListener | ( | const std::shared_ptr< LoggingServiceListener > & | listener | ) |

Add an application listener to the LoggingService instance.

Parameters

  listener | the application listener

## ◆ debug()

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

Write a LinphoneLogLevelDebug message to the logs.

Parameters

  message | The log message.

## ◆ enableStackTraceDumps()

LINPHONECXX_PUBLIC void linphone::LoggingService::enableStackTraceDumps | ( | bool | enable | ) |

Allow Linphone to set handlers for catching exceptions and write the stack trace into log.

Available for Windows. It keeps old handlers.

Parameters

  enable | if true global handlers will be prepend by the logger handlers. By default, it is false.

## ◆ error()

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

Write a LinphoneLogLevelError message to the logs.

Parameters

  message | The log message.

## ◆ fatal()

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

Write a LinphoneLogLevelFatal message to the logs.

Parameters

  message | The 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

  message | The log message.

## ◆ removeListener()

LINPHONECXX_PUBLIC void linphone::LoggingService::removeListener | ( | const std::shared_ptr< LoggingServiceListener > & | listener | ) |

Remove a previously added listener from the LoggingService instance.

Parameters

  listener | the application listener

## ◆ setDomain()

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

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

Parameters

  domain | The 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

  maxSize | The 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

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

  mask | Example: 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

  message | The log message.

## ◆ warning()

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

Write a LinphoneLogLevelWarning message to the logs.

Parameters

  message | The log message.

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

- logging_service.hh