{"id":27639345,"url":"https://github.com/xspyhack/keldeo","last_synced_at":"2025-07-20T13:33:47.921Z","repository":{"id":56917848,"uuid":"146065693","full_name":"xspyhack/Keldeo","owner":"xspyhack","description":"A lightweight logging library written in Swift.","archived":false,"fork":false,"pushed_at":"2019-09-23T10:03:54.000Z","size":136,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T22:47:00.877Z","etag":null,"topics":["logger","logging","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xspyhack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-25T04:47:01.000Z","updated_at":"2019-09-23T10:03:56.000Z","dependencies_parsed_at":"2022-08-21T03:50:57.592Z","dependency_job_id":null,"html_url":"https://github.com/xspyhack/Keldeo","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/xspyhack/Keldeo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xspyhack%2FKeldeo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xspyhack%2FKeldeo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xspyhack%2FKeldeo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xspyhack%2FKeldeo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xspyhack","download_url":"https://codeload.github.com/xspyhack/Keldeo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xspyhack%2FKeldeo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135014,"owners_count":23881774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logger","logging","swift"],"created_at":"2025-04-23T22:15:32.215Z","updated_at":"2025-07-20T13:33:47.893Z","avatar_url":"https://github.com/xspyhack.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keldeo\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/xspyhack/keldeo/actions\"\u003e\u003cimg src=\"https://github.com/xspyhack/keldeo/workflows/Build/badge.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"http://cocoadocs.org/\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/Keldeo.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA lightweight logging library written in Swift.\n\n## Requirements\n\nSwift 5.0, iOS 12.0\n\n## Installation\n\nCocoaPods, Carthage, Swift Package Manager\n\n## Examples\n\n1. Add loggers\n```swift\nlet formatter = AlligatorFormatter() // Your custom Formatter\n\n// Add Xcode Console logger\nlet consoleLogger = ConsoleLogger(level: .debug, formatter: formatter)\nLogger.shared.add(AnyLogger(consoleLogger))\n\n// Add File logger\nlet fileManager = DefaultFileManager() // Your custom FileManager\nif let fileLogger = FileLogger(level: .info, formatter: formatter, fileManager: fileManager) {\n    Logger.shared.add(AnyLogger(fileLogger))\n}\n\n// Or maybe you want to use Apple Unified Logging system (OSLog)\n{ \n    let osLogger = OSLogger(level: .info, formatter: OSLogFormatter(), log: .default)\n    Logger.shared.add(AnyLogger(consoleLogger))\n}\n```\n\n2. Log message\n\n```swift\nLog.i(\"Keldeo is a lightweight logging library written in Swift.\") // info level\n// Xcode Console ouput: 🐊 2018-08-23 23:33:33.3333 [ViewController.swift:23] viewDidLoad() | Keldeo is a lightweight logging library written in Swift.\n// /caches/com.xspyhack.logs/2018-08-23-23-33-33.log output: 🐊 2018-08-23 23:33:33.3333 [ViewController.swift:23] viewDidLoad() | Keldeo is a lightweight logging library written in Swift.\n\nLog.d(\"This is a debug message\")\nLog.w(\"This is a warning message\")\nLog.e(\"This is an error message\")\n```\n\n## Advanced\n\n### Creating Custom Logger\n\n```swift\npublic struct WebLogger: Logging {\n    public var formatter: Formatter\n    public var level: Level\n\n    public var name: String {\n        return \"com.xspyhack.WebLogger\"\n    }\n\n    public init(level: Level = .info, formatter: Formatter) {\n        self.level = level\n        self.formatter = formatter\n    }\n\n    public func log(message: Message) {\n        // Send to web\n    }\n\n    public func start() {\n        // Setup connection\n    }\n\n    public func teardown() {\n        // Close connection\n    }\n}\n```\n\nThe Logger needs conform to protocol `Hashable`.\n\n```swift\nextension WebLogger: Hashable {\n    public static func == (lhs: WebLogger, rhs: WebLogger) -\u003e Bool {\n        return lhs.level == rhs.level \u0026\u0026 lhs.name == rhs.name\n    }\n\n    public func hash(into hasher: inout Hasher) {\n        hasher.combine(name)\n        hasher.combine(level)\n    }\n}\n```\n\n### Formatting Log Messages\n\n```swift\nstruct OSLogFormatter: Keldeo.Formatter {\n    func format(message: Message) -\u003e String {\n        var string = \"\"\n\n        let level: String\n        switch message.level {\n        case .error:\n            level = \"❌\"\n        case .warning:\n            level = \"⚠️\"\n        case .info:\n            level = \"🐊\"\n        case .debug:\n            level = \"💊\"\n        case .off:\n            level = \"\"\n        }\n        string += \"\\(level) \"\n\n        let file = (message.file as NSString).lastPathComponent\n        string += \"[\\(file):\\(message.line)] \\(message.function) \"\n\n        string += \"| \\(message.message)\"\n\n        return string\n    }\n}\n```\n\n### Log Levels\n\nThere are several log levels employed by Keldeo, which correspond to the different types of messages the logger may need to process.\n\n```swift\nenum Level {\n    case off, error, warning, info, debug\n}\n```\n\n```swift\nlet consoleLogger = ConsoleLogger(level: .debug, formatter: formatter) // can capture all level log message\nlet osLogger = OSLogger(level: .info, formatter: OSLogFormatter(), log: .default) // can capture `error`, `warning` and `info` level log message\nlet fileLogger = FileLogger(level: .error, formatter: formatter, fileManager: fileManager) // only capture `error` level log message\nlet disabledLogger = ConsoleLogger(level: .off, formatter: formatter) // won't capture any log message\n\nLog.d(\"This message should be processed by `consoleLogger`\")\nLog.i(\"This message should be processed by `consoleLogger` and `osLogger`\")\nLog.w(\"This message should be processed by `consoleLogger` and `osLogger`\")\nLog.e(\"This message should be processed by `consoleLogger`, `osLogger` and `fileLogger`\")\n\n```\n\n## License\n\nKeldeo is available under the MIT License. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxspyhack%2Fkeldeo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxspyhack%2Fkeldeo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxspyhack%2Fkeldeo/lists"}