FileTarget
open class FileTarget : Target
Target class for logging to a file.
-
Base directory URL for logged files.
Declaration
Swift
public lazy var baseLogDirectory: URL { get set }
-
URL of main log file.
Declaration
Swift
public lazy var logFileUrl: URL { get set }
-
URL of archive folder.
Declaration
Swift
public lazy var archiveUrl: URL { get set }
-
Config struct assigned during initialization.
Declaration
Swift
public let config: FileTargetConfig
-
File handle of a current log file being written to.
Declaration
Swift
public var fileHandle: FileHandle?
-
Initializes FileTarget instance with provided FileTargetConfig struct. Prepares file for receiving and persisting log messages.
Declaration
Swift
public init(_ config: FileTargetConfig? = nil, dispatchQueue: DispatchQueue? = nil)
Parameters
config
struct encapsulating logging preferences. Defaults to struct instance with defaults values.
dispatchQueue
dispatch queue to use for prossing log messages. Defaults to
DispatchQueue.io
-
Declaration
Swift
open func send(_ message: Message)
-
Undocumented
Declaration
Swift
open func formatted(_ message: Message) -> String
-
Forces archive process of the current log file regardless of the preconditions set in config files. Non-blocking. Thread-safe.
Declaration
Swift
public func forceArchive(_ completionHandler: @escaping (() -> Void))
Parameters
completionHandler
the block to execute when archiving as completed
-
Ensures that any in-memory or previously submitted async log calls are written in persistence storage.
Declaration
Swift
public func sync()