RotatingFileEndpoint

public class RotatingFileEndpoint: LXEndpoint

An Endpoint that writes Log Entries to a set of numbered files. Once a file has reached its maximum file size, the Endpoint automatically rotates to the next file in the set.

The notifications LXFileEndpointWillRotateFilesNotification and LXFileEndpointDidRotateFilesNotification are sent to the default notification center directly before and after rotating log files.

  • The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint.

    Declaration

    Swift

    public var minimumPriorityLevel: LXPriorityLevel
  • The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string.

    Declaration

    Swift

    public var dateFormatter: LXDateFormatter
  • The formatter used by this Endpoint to serialize each Log Entry to a string.

    Declaration

    Swift

    public var entryFormatter: LXEntryFormatter
  • This Endpoint requires a newline character appended to each serialized Log Entry string.

    Declaration

    Swift

    public let requiresNewlines: Bool = true
  • The URL of the directory in which the set of log files is located.

    Declaration

    Swift

    public let directoryURL: NSURL
  • Initialize a Rotating File Endpoint.

    If the specified file cannot be opened, or if the index-prepended URL evaluates to nil, the initializer may fail.

    Declaration

    Swift

    public init?(
            baseURL: NSURL? = defaultLogFileURL,
            numberOfFiles: UInt = 5,
            maxFileSizeKiB: UInt? = 1024,
            minimumPriorityLevel: LXPriorityLevel = .All,
            dateFormatter: LXDateFormatter = LXDateFormatter.standardFormatter(),
            entryFormatter: LXEntryFormatter = LXEntryFormatter.standardFormatter()
        )

    Parameters

    baseURL

    The URL used to build the rotating file set’s file URLs. Each file’s index number will be prepended to the last path component of this URL. Defaults to Application Support/{bundleID}/logs/{number}_log.txt. Must not be nil.

    numberOfFiles

    The number of files to be used in the rotation. Defaults to 5.

    maxFileSizeKiB

    The maximum file size of each file in the rotation, specified in kilobytes. Passing nil results in no limit, and no automatic rotation. Defaults to 1024.

    minimumPriorityLevel

    The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint. Defaults to .All.

    dateFormatter

    The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string. Defaults to .standardFormatter().

    entryFormatter

    The formatter used by this Endpoint to serialize each Log Entry to a string. Defaults to .standardFormatter().

  • The URL of the log file currently in use. Manually modifying this file is not recommended.

    Declaration

    Swift

    public var currentURL: NSURL
  • Writes a serialized Log Entry string to the currently selected file.

    Declaration

    Swift

    public func write(string: String)
  • Clears the currently selected file and begins writing again at its beginning.

    Declaration

    Swift

    public func resetCurrentFile()
  • Instructs the Endpoint to rotate to the next log file in its sequence.

    Declaration

    Swift

    public func rotate()