Endpoints are responsible for processing and writing Log Entries to the destinations they represent. LogKit includes several built-in Endpoints for various logging needs, but application developers can also create their own.

Endpoints are specified when a Logger instance is initialized. A Logger instance can include several Endpoints, and each Endpoint can be configured independently.

Included Endpoints

LogKit includes the following Endpoints ready for use:

Each of these included Endpoint types has unique settings and characteristics. View each specific Endpoint’s documentation to learn about initializing and using that Endpoint.

Creating a Custom Endpoint

If the included Endpoint types do not meet your needs, LogKit makes it easy to create a custom Endpoint for use within your application. Simply define an object that conforms to LogKit’s Endpoint protocol, and include it when initializing your Logger. The protocol defines a few properties that control which Log Entries an Endpoint will accept and how the Entries will be formatted, as well as a method for writing Log Entries to the destination the Endpoint represents.

The Endpoint Protocol

The LXEndpoint protocol defines the following required properties:

minimumPriorityLevel LXPriorityLevel The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint
dateFormatter LXDateFormatter The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string
entryFormatter LXEntryFormatter The formatter used by this Endpoint to serialize each Log Entry to a string
requiresNewlines Bool Indicates whether this Endpoint requires a newline character appended to each serialized Log Entry string

When a Log Entry meets an Endpoint’s Priority Level requirements, and has been serialized to a string by the Endpoint’s formatters, that string is passed to the Endpoint’s write: method for output to its final destination. In the write: method, an Endpoint creator should print the string to the console, append it to a log file, or send it to whatever destination your Endpoint represents.

write(string:String) Writes a serialized Log Entry string to the final destination this Endpoint represents

Example Endpoint

Below is the code for an example custom Endpoint called MyPrintEndpoint. This Endpoint prints Log Entries to Xcode’s debug console.

class MyPrintEndpoint: LXEndpoint {
    var minimumPriorityLevel: LXPriorityLevel
    var dateFormatter: LXDateFormatter
    var entryFormatter: LXEntryFormatter
    let requiresNewlines = false                // Always false for this Endpoint, because print() appends a newline automatically

    init(minimumPriorityLevel: LXPriorityLevel, dateFormatter: LXDateFormatter, entryFormatter: LXEntryFormatter) {
        self.minimumPriorityLevel = minimumPriorityLevel
        self.dateFormatter = dateFormatter
        self.entryFormatter = entryFormatter

    func write(string: String) {

To use this custom Endpoint, a developer would include it when initializing their Logger:

let log = LXLogger(endpoints: [
    MyPrintEndpoint(minimumPriorityLevel: .All, dateFormatter: LXDateFormatter.standardFormatter(), entryFormatter: LXEntryFormatter.standardFormatter())

The Logger instance will use its Endpoints’ settings to convert each Log Entry to a string, before asking the Endpoint to write it.