Improve logging system
What's new
This new logging api provides more flexibility than the former one.
- Full libvlc log context is handled when log messages are dispatched and a simple message formatter for file and console logging provides a way to control the context verbosity with option flags
- Log types are now handled with logger objects, VLCKit provides simple file and console loggers and you can provide custom ones using the new
VLCLogging
protocol - You can use multiple loggers at the same time
The legacy api is still functional for v3 but marked as deprecated. It will be removed in v4.
Examples
Using a VLCKit file logger to write debug logs with verbose context
let fileHandle = FileHandle(forUpdatingAtPath: path)
let logger = VLCFileLogger(fileHandle: fileHandle)
logger.level = .debug
logger.formatter.contextFlags = .levelContextAll
player.libraryInstance.loggers = [logger]
Using a VLCKit console logger to print logs with modules info
let logger = VLCConsoleLogger()
logger.level = .info
logger.formatter.contextFlags = .levelContextModule
player.libraryInstance.loggers = [logger]
Using two VLCKit loggers
let fileHandle = FileHandle(forUpdatingAtPath: path)
let fileLogger = VLCFileLogger(fileHandle: fileHandle)
fileLogger.level = .debug
fileLogger.formatter.contextFlags = .levelContextAll
let consoleLogger = VLCConsoleLogger()
consoleLogger.level = .info
consoleLogger.formatter.contextFlags = .levelContextModule
player.libraryInstance.loggers = [fileLogger, consoleLogger]
Edited by Felix Paul Kühne