LogService¶
-
enum
SeverityLevel
¶ 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.
-
enumerator
-
class
cppmicroservices::logservice
::
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:
LOG_ERROR
LOG_WARNING
LOG_INFO
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.