WriterConcurrencyMode

public enum WriterConcurrencyMode

Mode to run a specific Writer in. Used to wrap a writer to change the specific mode it operates in.

See also

TraceLog.configure(writers:environment:) for usage.
  • Direct, as the name implies, will directly call the writer from the calling thread with no indirection. It will block until the writer(s) in this mode have completed the write to the endpoint.

    Useful for scripting applications and other applications where it is required for the call not to return until the message is printed.

    Declaration

    Swift

    case direct(Writer)
  • Synchronous blocking mode is similar to direct in that it blocks but this mode also uses a queue for all writes. The benefits of that is that all threads writing to the log will be serialized through before calling the writer (one call to the writer at a time).

    Declaration

    Swift

    case sync(Writer)
  • Asynchronous non-blocking mode. A general mode used for most application which moves processing of the write to a background queue for minimal delays when logging.

    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.

    See also

    AsyncConcurrencyModeOption for details.

    Declaration

    Swift

    public static func async(_ writer: Writer, options: Set<AsyncConcurrencyModeOption> = []) -> WriterConcurrencyMode

    Parameters

    writer

    The Writer instance to enable async mode for.

    options

    An array specifying the optional features to configure for the writer.