logReportsManager
Use the logReportsManager to use your own logger object and receive log messages for your required log levels.
Overview
The Bringg Driver SDK for iOS logReportsManager allows you to initialize an object as the logger to receive log messages for your required log levels. You set the log level requirements and all log messages meeting those requirements are logged to your specified object. Log message levels include
- errors
- warnings
- informational messages
- debugging messages
Host App Development
logReportsManager is very useful during host app development and debugging.
Objective-C
You can adapt the logReportsManager into Objective-C.
LoggerProtocol
The following is the LoggerProtocol:
@objc public protocol LoggerProtocol {
func logDebug(_ message: String, file: String, function: String, line: UInt)
func logInfo(_ message: String, file: String, function: String, line: UInt)
func logWarn(_ message: String, file: String, function: String, line: UInt)
func logError(_ message: String, file: String, function: String, line: UInt)
}
Feature Summary
Method Name |
Method Functionality |
Logs error messages, only. |
|
Logs messages at the warnings level, including:
|
|
Logs messages at the info level, including:
|
|
Logs messages at the debug level, including:
|
Initializing a Logger Object
Step 1. Conforming to LoggerProtocol
Your class must conform to the LoggerProtocol.
For example, Logger must conform to LoggerProtocol.
class Logger: **LoggerProtocol ** {
Step 2. Implementing LoggerProtocol methods
Implement the LoggerProtocol methods in your logger class.
For example, Logger implements logDebug, logInfo, logWarn, and logError using CocoaLumberjack.
class Logger: **LoggerProtocol** { func **logDebug**(_ message: String, file: String, function: String, line: UInt) { DDLogDebug(Logger.format(message, file: file, function: function, line: line), ddlog: ddLog) } func **logInfo**(_message: String, file: String, function: String, line: UInt) { DDLogInfo(Logger.format(message, file: file, function: function, line: line), ddlog: ddLog) } func **logWarn**(_message: String, file: String, function: String, line: UInt) { DDLogWarn(Logger.format(message, file: file, function: function, line: line), ddlog: ddLog) } func **logError**(_message: String, file: String, function: String, line: UInt) { DDLogError(Logger.format(message, file: file, function: function, line: line), ddlog: ddLog) }
Step 3: Initializing the BringgDriverSDK with a Logger Object
In AppDelegate.swift, call initializeSDK, and pass it your logger object.
import BringgDriverSDK class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Initialize Bringg SDK. **Bringg.initializeSDK(logger: Logger())** } }
Example of a Logger
The Bringg-iOS-DriverSDK repo includes an example logger using CocoaLumberjack.
logReportsManager Methods
logReportsManager Methods Parameters
All of the logReportsManager methods use the parameter list.
Method Parameters
file String |
REQUIRED The name of the file to which the log message refers. |
function String |
REQUIRED The name of the function to which the log message refers. |
message String |
REQUIRED The log message text. |
line UInt |
REQUIRED The line number in the file to which the log message refers. |
logDebug(_ message:file:function:line:)
Use to log debugging messages. For the parameter descriptions, see Parameters.
func logDebug(_ message: String, file: String, function: String, line: UInt)
logInfo(_ message:file:function:line:)
Use to log debugging messages. For the parameter descriptions, see Parameters.
func logInfo(_ message: String, file: String, function: String, line: UInt)
logWarn(_ message:file:function:line:)
Use to log debugging messages. For the parameter descriptions, see Parameters.
func logWarn(_ message: String, file: String, function: String, line: UInt)
logError(_ message:file:function:line:)
Use to log debugging messages. For the parameter descriptions, see Parameters.
func logError(_ message: String, file: String, function: String, line: UInt)
Updated over 6 years ago