LogService

enum class SeverityLevel : uint8_t

Values:

enumerator LOG_ERROR

Indicates the bundle or service may not be functional.

Action should be taken to correct this situation.

enumerator LOG_WARNING

Indicates a bundle or service is still functioning but may experience problems in the future because of the warning condition.

enumerator LOG_INFO

May be the result of any change in the bundle or service and does not indicate a problem.

enumerator LOG_DEBUG

Used for problem determination and may be irrelevant to anyone but the bundle developer.

class LogService
#include <cppmicroservices/logservice/LogService.hpp>

Provides methods for bundles to write messages to the log.

LogService methods are provided to log messages; optionally with a ServiceReference object or an exception. Bundles must log messages in the OSGi environment with a severity level according to the following hierarchy:

  1. LOG_ERROR

  2. LOG_WARNING

  3. LOG_INFO

  4. LOG_DEBUG

Remark

This class is thread safe.

Public Functions

virtual ~LogService() = default
virtual void Log(SeverityLevel level, std::string const &message) = 0

Logs a message.

Parameters:
  • level – The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.

  • message – Human readable string describing the condition or empty string.

virtual void Log(SeverityLevel level, std::string const &message, const std::exception_ptr ex) = 0

Logs a message.

Parameters:
  • level – The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.

  • message – Human readable string describing the condition or empty string.

  • ex – The exception that reflects the condition or nullptr.

virtual void Log(ServiceReferenceBase const &sr, SeverityLevel level, std::string const &message) = 0

Logs a message.

Parameters:
  • sr – The ServiceReferenceBase object of the service that this message is associated with or an invalid object.

  • level – The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.

  • message – Human readable string describing the condition or empty string.

virtual void Log(ServiceReferenceBase const &sr, SeverityLevel level, std::string const &message, const std::exception_ptr ex) = 0

Logs a message with an exception associated and a ServiceReference object.

Parameters:
  • sr – The ServiceReferenceBase object of the service that this message is associated with or an invalid object.

  • level – The severity of the message. This should be one of the defined log levels but may be any integer that is interpreted in a user defined way.

  • message – Human readable string describing the condition or empty string.

  • ex – The exception that reflects the condition or nullptr.