Logger
public class Logger
An internal logger system. Messages are written into text files stored in the application sandbox directory.
No system logging like OSLog or a third-party solution is used, so should be no conflict if you use such.
Old log files will be removed to save disk space.
The time interval for rolling out files can be configured via rollingFrequency
and maximumNumberOfLogFiles
.
-
Logger is enabled by default.
It’s not recommended to disable it as there will be no helpful data to investigate possible issues.
Declaration
Swift
public var enabled: Bool
-
The logs console output data amount level. The default is
error
.Declaration
Swift
public var level: LoggingLevel
-
Frequency for creating a new log file. Older log files will be removed when
maximumNumberOfLogFiles
will be reached.The default is 1 week. Measured in seconds.
Declaration
Swift
public var rollingFrequency: TimeInterval { get set }
-
A maximum number of log files stored locally. Each file contains logs per time interval set in
rollingFrequency
.The older files will be automatically removed. The default is 4.
Declaration
Swift
public var maximumNumberOfLogFiles: Int { get set }
-
The logs files directory.
Declaration
Swift
public var logsDirectory: URL { get }
-
Export logs file to send for investigating.
The file is generated in a background thread and the completion block is called on
notifyOnQueue
thread. All text logs files will be archived into one zip archive file.Declaration
Swift
public func exportLogs(notifyOnQueue: DispatchQueue = .main, completion: @escaping (_ fileUrl: URL?, _ error: Error?) -> Void)
Parameters
notifyOnQueue
A queue to call a
completion
block on. The default is the main thread.completion
Block called with an exported zip file URL or an error. The file will be stored in the default temporary directory. You are responsible for removing that file when not needed anymore.
-
Export logs file to send for investigating.
This method executes synchronously, blocking the current thread until finished generating the logs file. All text logs files will be archived into one zip archive file.
Declaration
Swift
public func exportedLogs() -> (fileUrl: URL?, error: Error?)
Return Value
A tuple with an exported zip file URL or an error. The file will be stored in the default temporary directory. You are responsible for removing that file when not needed anymore.