Logger
@objc open class Logger: NSObject, LoggerProtocol
Provides Logging support for the SDK.
On iOS 9 and below and macOS El Capitan and below this class will use the Apple NSLog-style logs.
When running in iOS 10+ and macOS Sierra+ this class will use the Apple Unified Logging API
-
Shared instance of the Logger class
Declaration
Swift
public static var shared: LoggerProtocol = Logger()
-
Sets the shared instance of the Logger class.
Can be used to replace Logger functionality with subclassed Logger, or new implementation of LoggerProtocol.
Declaration
Swift
public static func setSharedLogger(logger: LoggerProtocol)
-
Initialization
Declaration
Swift
public override init()
-
Used to override the logging functionality just before it’s sent to the system logger.
If a closure is provided, this closure will be called with a fully-formed log string instead of being sent to the standard platform logging system.
Declaration
Swift
open func setLogLineWriterClosure(_ writerBlock: ((String) -> Void)?)
-
Sets and gets the current logger verbosity level. Logs more verbose than this level will not be output to the logging system.
For example:
If the loggerLevel is set to
LoggerLevel.info
, then:Logger.shared.loggerlevel = LoggerLevel.info
Logger.warn("this will be output")
Logger.info("this will be output")
Logger.debug("this will not be output")
Logger.trace("this will not be output")
Declaration
Swift
open var loggerLevel: LoggerLevel
-
Return true if the log level will output trace level messages.
Declaration
Swift
open func isTraceEnabled() -> Bool
-
log a trace message.
Declaration
Swift
open func trace(_ log: String)
-
Return true if the log level will output debug level messages.
Declaration
Swift
open func isDebugEnabled() -> Bool
-
log a debug message.
Declaration
Swift
open func debug(_ log: String)
-
Return true if the log level will output info level messages.
Declaration
Swift
open func isInfoEnabled() -> Bool
-
log a info message.
Declaration
Swift
open func info(_ log: String)
-
Return true if the log level will output warning level messages.
Declaration
Swift
open func isWarnEnabled() -> Bool
-
log a warning message.
Declaration
Swift
open func warn(_ log: String)
-
Return true if the log level will output error level messages.
Declaration
Swift
open func isErrorEnabled() -> Bool
-
log a error message.
Declaration
Swift
open func error(_ log: String)
-
Return true if the log level will output fatal level messages.
Declaration
Swift
open func isFatalEnabled() -> Bool
-
log a fatal message.
Declaration
Swift
open func fatal(_ log: String)
-
Return true if logging is disabled and nothing will be logged.
Declaration
Swift
open func isLoggingOff() -> Bool
-
Shortcut to default logger: Return true if the log level will output trace level messages.
Declaration
Swift
public static func isTraceEnabled() -> Bool
-
Shortcut to default logger: log a trace message.
Declaration
Swift
public static func trace(_ log: String)
-
Shortcut to default logger: Return true if the log level will output debug level messages.
Declaration
Swift
public static func isDebugEnabled() -> Bool
-
Shortcut to default logger: log a debug message.
Declaration
Swift
public static func debug(_ log: String)
-
Shortcut to default logger: Return true if the log level will output info level messages.
Declaration
Swift
public static func isInfoEnabled() -> Bool
-
Shortcut to default logger: log a info message.
Declaration
Swift
public static func info(_ log: String)
-
Shortcut to default logger: Return true if the log level will output warning level messages.
Declaration
Swift
public static func isWarnEnabled() -> Bool
-
Shortcut to default logger: log a warning message.
Declaration
Swift
public static func warn(_ log: String)
-
Shortcut to default logger: Return true if the log level will output error level messages.
Declaration
Swift
public static func isErrorEnabled() -> Bool
-
Shortcut to default logger: log a error message.
Declaration
Swift
public static func error(_ log: String)
-
Shortcut to default logger: Return true if the log level will output fatal level messages.
Declaration
Swift
public static func isFatalEnabled() -> Bool
-
Shortcut to default logger: log a fatal message.
Declaration
Swift
public static func fatal(_ log: String)
-
Shortcut to default logger: Return true if logging is disabled and nothing will be logged.
Declaration
Swift
public static func isLoggingOff() -> Bool