Slog 0.3.0

Slog 0.3.0

TestsTested โœ—
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2017
SwiftSwift Version 3.0
SPMSupports SPM โœ—

Maintained by John Stricker.




Apps WeekApps This Week 2
Test Targets2
Test WeekTests This week 2
powered by Segment


Pull Requests0


LOCLines of Code 98

Slog 0.3.0

  • By
  • johnstricker


A simple Swift logging library.

Basic use

Initialize with a default level, and if emojis should be included in logs:

let log = Slog(level: .warn, useEmoji: true)

Then you can log with functions for each of the log levels (with their associated emoji):

  • ๐Ÿ“– ย  verbose
  • ๐Ÿ ย  debug
  • โœ๏ธ ย  info
  • โš ๏ธ ย  warn
  • โ‰๏ธ ย  error
  • off

For example:

log.error("This is an error!")

Setting the level of a log will only print out those logs at that level or above.

log.level = .verbose

You can also initialize a log with a name. You may want to have different logs for App Lifecycle, API, UI, Data, etc. This would allow you to have different logs & set different log levels depending upon what you are trying to monitor or track down. The log name will be printed out as part of any log message for that log.

let lifeCycleLog = Slog(name:"LifeCycle", level: .verbose, useEmoji: true)

You could use this log in the AppDelegate to monitor app lifecycles. For example putting this code in didFinishLaunchingWithOptions:

lifeCycleLog.verbose("App finished launching with options \(launchOptions)")

would print:

๐Ÿ“–|LifeCycle|2017-03-23 10:55:37.193 AppDelegate.swift application(_:didFinishLaunchingWithOptions:) line 22:
App did finish launching with options: nil```

## Check and Report (under development)
Checks are designed to check if a condition is fulfilled, if it is not then an error is reported. Each check method should have a corresponding report method (though you can have report methods without a matching check method).

This is currently under development, so feel free to suggest new checks & reports as issues (or PRs).

### Checks
  // index is within the bounds of an array
  check(index:, isInBoundsOf:)


  // index is out of bounds of an array
  report(index:, outOfBoundsOf: )

  // unxpected nil for a variable

Example Project

To run the example project, clone the repo, and run pod install from the Example directory first.


Slog is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Slog"

If you donโ€™t want to use the check and report features, then you can use the LogOnly subspec:

pod "Slog/LogOnly"


johnstricker, [email protected]


Slog is available under the MIT license. See the LICENSE file for more info.