Swiftpack.co - ohetzendorfer/SimpleLogger as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ohetzendorfer.
ohetzendorfer/SimpleLogger 2.1.0
Simple logging in Swift with topics
⭐️ 1
🕓 1 week ago
.package(url: "https://github.com/ohetzendorfer/SimpleLogger.git", from: "2.1.0")


Simple logging with self defined topics.

🐵 VERBOSE        21:52:16.540        logging something
🐸 DEBUG          21:52:16.540        is this working?
🦊 ERROR          21:53:16.540        Upsie, that should not have happened
// 2022-11-20.log
🦊 ERROR          21:53:16.540        Upsie, that should not have happened


Add this swift package to your project.


Create logger topics, setup and start logging.

Create topics

A topic can either be used to represent a specific severity, like in the sample below, or it can be used to define particular areas of your application you wish to log information for. E.g. a specific module, a remote client or whatever parts your application consists of.

The topic has a title, a icon and two boolean flags: printInConsole and writeToFile. These booleans define if your logs should appear as output on the console and if they should be written to a log file on the device itself.

If you enable the writeToFile flag the library will create a directory in your app's Documents folder named logs. In this directory there will be a unique subfolder in which you will find log files per day that contain all logs that return true for the writeToFile flag. The directory containing the logs can be retrieved using the function Logger#getLogDirectoryUrl.

enum MyTopic: String, LoggerTopic {
    case verbose, debug, error

    var title: String {
        switch self {
        case .verbose: return "INFO"
        case .debug, .error: return rawValue.uppercased()

    var icon: Character {
        switch self {
        case .verbose: return "🐵"
        case .debug: return "🐸"
        case .error: return "🦊"
    public var printInConsole: Bool {
        switch self {
        case .verbose, .error: return true
        case .debug: return false
    public var writeToFile: Bool {
        switch self {
        case .error: return true
        case .verbose, .debug: return false


let logger = Logger(
    topicType: MyTopic.self,
    defaultTopic: .verbose


logger.output("logging something") // using default .verbose
logger.output("is this working?", .debug)
logger.output("Upsie, that should not have happened", .error)


Stars: 1
Last commit: 3 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics