VGF Logging C++ API
The VGF Library produces logging messages. The Logging C++ API allows you to process these logging messages. To enable the logging functionality, you must provide the callback function. The callback function accepts log level and message as input parameters:
#include "vgf/logging.hpp"
using namespace mlsdk::vgflib::logging;
void loggingCallback(LogLevel logLevel, const std::string& message) {
// Implementation of the logging callback
}
EnableLogging(loggingCallback);
To disable logging, use the following function:
#include "vgf/logging.hpp"
using namespace mlsdk::vgflib::logging;
DisableLogging();
Logging API reference
-
enum class LogLevel
Enum for the log levels.
Values:
-
enumerator INFO
-
enumerator WARNING
-
enumerator DEBUG
-
enumerator ERROR
-
enumerator INFO
-
using LoggingCallback = std::function<void(LogLevel logLevel, const std::string &message)>
Type definition for the logging callback.
- Param logLevel:
Log level of the message
- Param message:
Log message
-
std::ostream &operator<<(std::ostream &os, const LogLevel &logLevel)
Support LogLevel in std::ostream output operator.
- Parameters:
os -- Reference to the std::ostream instance
logLevel -- Log level
- Returns:
Reference to the std::ostream instance
-
void EnableLogging(const LoggingCallback &callback)
Enables logging functionality.
- Parameters:
callback -- Callback that should be used for processing the log messages
-
void DisableLogging()
Disables logging functionality.