Logger
@objc(BMPLogger)
public protocol Logger
This protocol can be implemented to gather more detailed information about what is happening within the SDK
for all top-level entities and APIs. For example, Player
, Source
and PlayerView
entities,
as well as Offline components.
It is implemented by default within the SDK to print a single log entry to the console.
A log entry contains details such as log level, which entity or API is sending the log, a log message,
the date and time the log entry was created, and if applicable,
a warning or error code and extra data about the warning or error.
See LogEntry
for more details.
To create your own custom logger to receive and optionally print a log entry in your integration, provide an instance that conforms to this protocol. An example custom logger is:
public class CustomLogger: Logger {
public var level: LogLevel = .info
func log(_ logEntry: LogEntry) {
var logDetails: [String] = []
logDetails.append("[\(logEntry.sender)]")
logDetails.append("[\(logEntry.level)]")
logDetails.append("\(logEntry.message)")
if let code = logEntry.code {
logDetails.append("code: \(code)")
}
if let data = logEntry.data {
var dataDetails: [String] = []
dataDetails.append("Data code: \(data.code), message: \(data.message)")
if let dataError = data.underlyingError {
dataDetails.append("underlying error: \(dataError)")
}
logDetails.append("[" + dataDetails.joined(separator: ", ") + "]")
}
print("[CustomLog] \(logDetails.joined(separator: " "))")
}
}
To implement your custom logger, assign it as the logger in the logging config:
DebugConfig.logging.logger = CustomLogger()
-
The minimum log level that is used to filter log output.
Default minimum level is
.warning
.Declaration
Swift
var level: LogLevel { get set }