SwifterLog is a utility to create logging information at multiple levels and send this to multiple targets.

While created for Swiftfire, it is completely functional on its own and can be used in other projects as well.


It offers the following features:

  1. 8 different log levels
    • DEBUG (0)
    • INFO (1)
    • NOTICE (2)
    • WARNING (3)
    • ERROR (4)
    • CRITICAL (5)
    • ALERT (6)
    • EMERGENCY (7)
  2. Send the log information to 5 different destinations
    • STDOUT (Console output in Xcode or on the command line)
    • FILE
    • ASL (Apple System Log Facility)
    • NETWORK (A -remote- destination on the network)
    • CALLBACK (A callback to the application that uses SwifterLog)
  3. The logging information consist of 5 parts:
    • Timestamp
    • Loglevel
    • General purpose ID (32 bit integer)
    • Originating location
    • Message from the module that placed the logging call
  4. A ReflectedStringConvertible protocol (implementation) is provided to allow easy logging of class members on any class instance.

A typical log entry would look as follows:

2016-05-23T12:09:03.150+0200, INFO   : ffffffff, main.Swiftfire.130, Listening for M&C connections

The above line would be created by the following: (at line 130 in file “main” function of “Swiftfire”)

let log = SwifterLog.theLogger

log.atLevelInfo("Listening for M&C connections")

The id parameter can be used to differentiate between threads, sockets, objects etc.

In addition to the logger singleton SwifterLog also provides high performance loggers for disabled levels. For example the debug and notice levels are not usually enabled in shipping applications. But allowing these calls to remain in a shipping application will degrade performance. However with optional chaining on the atDebug and atNotice loggers the big hit on runtime performance can be avoid at a small cost. Allowing these calls to remain in the shipping code.

typealias Log = SwifterLog

Reference manual

Open the following information in a new window (or tab)