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 LXLogEndpoint protocol defines the following required properties:

minimumLogLevel LXLogLevel The minimum Priority Level a Log Entry must meet to be accepted by this Endpoint
dateFormatter NSDateFormatter The formatter used by this Endpoint to serialize a Log Entry’s dateTime property to a string
entryFormatter LXLogEntryFormatter The formatter used by this Endpoint to serialize each Log Entry to a 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: LXLogEndpoint {
    var minimumLogLevel: LXLogLevel
    var dateFormatter: NSDateFormatter
    var entryFormatter: LXLogEntryFormatter

    init(minimumLogLevel: LXLogLevel, dateFormatter: NSDateFormatter, entryFormatter: LXLogEntryFormatter) {
        self.minimumLogLevel = minimumLogLevel
        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(minimumLogLevel: .All, dateFormatter: defaultDateFormatter, entryFormatter: defaultEntryFormatter)

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