Strategy

public enum Strategy

A Strategy defines how FileWriter will manage file naming and physical file management.

  • Default file strategy which creates a fixed file and reuses the same file on every startup.

    Note

    There are no points of file rotation with this option, TraceLog will continue to append to the file name specified.

    Remark

    Once Swift Evolution SE-0155 is implemented this will func will be changed to a case in the enum with default values. We must use a func now to work around the lack of defaults on enums.

    Declaration

    Swift

    public static func fixed(fileName: String = "trace.log") -> Strategy

    Parameters

    fileName

    The file name to use for the logging file. The file name should be the name + any extension you would like to use but should not include the path component. Default is trace.log.

  • A strategy that includes rotation of the files at various points in time (E.g. at startup, a max file size, or a certain age of the file.)

    Remark

    Once Swift Evolution SE-0155 is implemented this func will be changed to a case in the enum with default values. We must use a func now to work around the lack of defaults on enums.

    Declaration

    Swift

    public static func rotate(at options: Set<RotationOption>, template: String = "'trace-'yyyyMMdd-HHmm-ss.SSSS'.log'") -> Strategy

    Parameters

    at

    A set of FileWriter.Strategy.RotationOption values specifying at what point to rotate the file that TraceLog writes to.

    template

    A Unicode String pattern to use to uniquely name new files. Internally TraceLog uses DateFormatter to format the log file names which means you can use any DateFormatter legal format. \ To ensure unique files during rotation, you must specify a format that includes a date component that will produce a unique file name for the granularity of file rotation. For instance passing ‘trace-'yyyyMMdd’.log’ would give you 1 day of granularity meaning that only one log file can be produced per day. \ Default is ‘trace-'yyyyMMdd-HHmm-ss.SSSS’.log’. \ The default template is suitable for any practical rotation granularity.

  • Options available for rotation strategy.

    See more

    Declaration

    Swift

    public enum RotationOption