LogKit is a logging framework built to be simple to get started with, efficient to execute, safe for shipping code, and extensible for flexibility. It is written in pure Swift and is suitable for OS X, iOS, tvOS, and watchOS application logging. For a developer looking for more power than print(), LogKit takes just a moment to get started with, and comes ready to log to the console, a file, an HTTP service, or all three. Need to log to somewhere else? Defining your own Endpoint is easy too.

Design

LogKit was designed with a few goals in mind:

Simplicity

LogKit comes ready to get you logging to the console in one line of code. With LogKit’s no-argument convenience initializer, you can skip the “where?” and “how?” questions for now, and come back to them later.

When you do want to begin logging to a file, or uploading log entries to an HTTP service, you’ll simply add more Endpoints to your Logger. All of your existing log calls will begin using the new Endpoints the next time you build your app.

LogKit comes with a variety of ready-built Endpoints for logging to the console, files, or HTTP services, with options like rotating files, dated filenames, and JSON output to HTTP.

Efficiency

LogKit is written with efficiency in mind. Where appropriate, LogKit uses Grand Central Dispatch to do the heavy lifting. However, the LogKit framework is not completely asynchronous - it does not always make sense for your log messages to (not) show up until after your app has crashed. LogKit attempts to find a balance between timely logging and vacating the main thread. LogKit also bails out early if none of its Endpoints care about a particular entry.

Safety

Your logging library should not crash your (shipping) application. LogKit was designed to silently drop Endpoints and logging calls that fail in shipping builds. In test builds, however, LogKit will abort so that issues do not go unnoticed.

Extensiblity

Although LogKit comes with a number of ready-built Endpoint options, developers may desire to create their own. LogKit provides a protocol that any object may adopt to become a log Endpoint. Conformance is straightforward with just a few properties and one method. LogKit allows you to send your logs wherever you like!