Logging
Switchboard SDK provides customizable and extensive logging to keep track of the internal processes. The Logger
outputs to the console by default.
Log Levels
The log levels are the following:
Log levels | Description |
---|---|
None | Set this to disable logging |
Error | Critical errors, crashes |
Warning | Warnings that can cause potentional unwanted results, e.g. clipping |
Info | General informational logs |
Debug | Useful informations for debugging purposes |
Trace | Verbose logs, for more in-depth look on functionality |
Setting the Log Level
The default log level is Info
, but you can change this to your desire.
- Swift
- Kotlin
- C++
SBLogger.setLogLevel(SBLogLevelDebug)
Logger.setLogLevel(LogLevel.Debug);
Logger::setLogLevel(LogLevel::Debug);
Custom Log Destination
It's also possible to set a custom log destination, for example writing every log into a file, while filtering what you want to display on the console.
- Swift
- Kotlin
- C++
SBLogger.setLogDestination(
CallbackLogDestination(logCallback: { (logLevel: SBLogLevel, message: String) in
// custom logging
})
)
Logger.setLogDestination(
CallbackLogDestination { logLevel, message ->
// custom logging
}
)
// You have to implement your own class by inheriting from the SDK provided `LogDestination` interface.
class CustomLogDestination : public switchboard::LogDestination {
void log(const LogLevel logLevel, const std::string& logMessage) {
// Use 'logLevel' and 'message' to form your log message
}
};
Logger::setLogDestination(CustomLogDestination());
Using Switchboard SDK for Logging
If you are developing a custom extension for Switchboard SDK we suggest that you use the Logger provided by the SDK.
- Swift
- Kotlin
- C++
SBLogger.error("Error log")
SBLogger.warning("Warning log")
SBLogger.info("Info log")
SBLogger.debug("Debug log")
SBLogger.trace("Trace log")
import com.synervoz.switchboard.sdk.logger.Logger
...
Logger.error("Error log")
Logger.warning("Warning log")
Logger.info("Info log")
Logger.ddebug("Debug log")
Logger.ttrace("Trace log")
Logger::error("Error log")
Logger::warning("Warning log")
Logger::info("Info log")
Logger::debug("Debug log")
Logger::trace("Trace log")