{"id":1338,"url":"https://github.com/SwiftyBeaver/SwiftyBeaver","last_synced_at":"2025-08-06T13:32:57.900Z","repository":{"id":37663895,"uuid":"47025785","full_name":"SwiftyBeaver/SwiftyBeaver","owner":"SwiftyBeaver","description":"Convenient \u0026 secure logging during development \u0026 release in Swift 4 \u0026 5","archived":false,"fork":false,"pushed_at":"2024-11-26T10:13:07.000Z","size":2481,"stargazers_count":5945,"open_issues_count":4,"forks_count":480,"subscribers_count":72,"default_branch":"master","last_synced_at":"2024-12-05T21:00:20.667Z","etag":null,"topics":["apple-tv","ios","logging","macos","server-side-swift","swift","swift-framework","swift4","swift5","swiftybeaver-platform","vapor"],"latest_commit_sha":null,"homepage":"https://swiftybeaver.com","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/SwiftyBeaver.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-28T14:08:37.000Z","updated_at":"2024-12-05T10:10:41.000Z","dependencies_parsed_at":"2024-11-28T20:03:55.358Z","dependency_job_id":null,"html_url":"https://github.com/SwiftyBeaver/SwiftyBeaver","commit_stats":{"total_commits":480,"total_committers":93,"mean_commits":5.161290322580645,"dds":0.3604166666666667,"last_synced_commit":"8e06e2ea17b8fc503f95e2d6026d503834413e60"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftyBeaver%2FSwiftyBeaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftyBeaver%2FSwiftyBeaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftyBeaver%2FSwiftyBeaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftyBeaver%2FSwiftyBeaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftyBeaver","download_url":"https://codeload.github.com/SwiftyBeaver/SwiftyBeaver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905520,"owners_count":17989779,"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":["apple-tv","ios","logging","macos","server-side-swift","swift","swift-framework","swift4","swift5","swiftybeaver-platform","vapor"],"created_at":"2024-01-05T20:15:44.144Z","updated_at":"2024-12-09T14:31:08.544Z","avatar_url":"https://github.com/SwiftyBeaver.png","language":"Swift","funding_links":[],"categories":["Logging","Libs","Server Side Utilities","Swift","Applications","Logger","Logging [🔝](#readme)","Other"],"sub_categories":["Other Hardware","Logging","Other free courses","Other","Downloader","Text","📦 Other (22)"],"readme":"\u003cp align=\"center\"\u003e\u003cb\u003eColorful\u003c/b\u003e, flexible, \u003cb\u003elightweight\u003c/b\u003e logging for Swift 3, Swift 4 \u0026 \u003cb\u003eSwift 5\u003c/b\u003e.\u003cbr/\u003eGreat for \u003cb\u003edevelopment \u0026 release\u003c/b\u003e with support for Console, file \u0026 cloud destinations for server-side Swift.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://swift.org\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Language-Swift%203,%204%20\u0026%205-orange.svg\" alt=\"Language Swift 2, 3, 4 \u0026 5\"\u003e\u003c/a\u003e \u003ca href=\"https://circleci.com/gh/SwiftyBeaver/SwiftyBeaver\" target=\"_blank\"\u003e\u003cimg src=\"https://circleci.com/gh/SwiftyBeaver/SwiftyBeaver/tree/master.svg?style=shield\" alt=\"CircleCI\"/\u003e\u003c/a\u003e\u003cbr/\u003e\u003cp\u003e\n\n---\n\n\u003cbr/\u003e\n\n### During Development: Colored Logging to Xcode Console via OSLog API or Print\n\n\u003cimg width=\"924\" alt=\"image\" src=\"https://github.com/SwiftyBeaver/SwiftyBeaver/assets/15070906/418a6a70-ced4-4000-91c3-8dc8fc235b7c\"\u003e\n\n\n#### In Xcode 15\n```Swift\n\n// use Apple's fancy OSLog API:\nlet console = ConsoleDestination()\nconsole.logPrintWay = .logger(subsystem: \"Main\", category: \"UI\")\n\n// or use good ol' \"print\" (which is the default):\nlet console = ConsoleDestination()\nconsole.logPrintWay = .print\n```\n#### In Xcode 8\n[Learn more](http://docs.swiftybeaver.com/article/9-log-to-xcode-console) about colored logging to Xcode 8 Console with Swift 3, 4 \u0026 5. For Swift 2.3 [use this Gist](https://gist.github.com/skreutzberger/7c396573796473ed1be2c6d15cafed34). **No need to hack Xcode 8 anymore** to get color. You can even customize the log level word (ATTENTION instead of ERROR maybe?), the general amount of displayed data and if you want to use the 💜s or replace them with something else 😉\n\n\u003cbr/\u003e\n\n### During Development: Colored Logging to File\n\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/564725/18608325/b7ecd4c2-7ce6-11e6-829b-7f8f9fe6ef2f.png\" width=\"738\"\u003e\n\n[Learn more](http://docs.swiftybeaver.com/article/10-log-to-file) about logging to file which is great for Terminal.app fans or to store logs on disk.\n\n\u003cbr/\u003e\n\n### Google Cloud \u0026 More\n\nYou can fully customize your log format, turn it into JSON, or create your own destinations. For example, our [Google Cloud Destination](https://github.com/SwiftyBeaver/SwiftyBeaver/blob/master/Sources/GoogleCloudDestination.swift) is just another customized logging format that adds the powerful functionality of automatic server-side Swift logging when hosted on Google Cloud Platform.\n\n\u003cbr/\u003e\n\n---\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Installation\n\n- For **Swift 4 \u0026 5** install the latest SwiftyBeaver version\n- For **Swift 3** install SwiftyBeaver 1.8.4\n- For **Swift 2** install SwiftyBeaver 0.7.0\n\n\u003cbr/\u003e\n\n### Carthage\n\nYou can use [Carthage](https://github.com/Carthage/Carthage) to install SwiftyBeaver by adding that to your Cartfile:\n\nSwift 4 \u0026 5:\n\n```Swift\ngithub \"SwiftyBeaver/SwiftyBeaver\"\n```\n\nSwift 3:\n\n```Swift\ngithub \"SwiftyBeaver/SwiftyBeaver\" ~\u003e 1.8.4\n```\n\nSwift 2:\n\n```Swift\ngithub \"SwiftyBeaver/SwiftyBeaver\" ~\u003e 0.7\n```\n\n\u003cbr/\u003e\n\n### Swift Package Manager\n\nFor [Swift Package Manager](https://swift.org/package-manager/) add the following package to your Package.swift file. Just Swift 4 \u0026 5 are supported:\n\n```Swift\n.package(url: \"https://github.com/SwiftyBeaver/SwiftyBeaver.git\", .upToNextMajor(from: \"2.0.0\")),\n```\n\n\u003cbr/\u003e\n\n### CocoaPods\n\nTo use [CocoaPods](https://cocoapods.org) just add this to your Podfile:\n\nSwift 4 \u0026 5:\n\n```Swift\npod 'SwiftyBeaver'\n```\n\nSwift 3:\n\n```Ruby\ntarget 'MyProject' do\n  use_frameworks!\n\n  # Pods for MyProject\n  pod 'SwiftyBeaver', '~\u003e 1.8.4'\nend\n```\n\nSwift 2:\n\n```Ruby\ntarget 'MyProject' do\n  use_frameworks!\n\n  # Pods for MyProject\n  pod 'SwiftyBeaver', '~\u003e 0.7'\nend\n\npost_install do |installer|\n  installer.pods_project.build_configurations.each do |config|\n    # Configure Pod targets for Xcode 8 with Swift 2.3\n    config.build_settings['SWIFT_VERSION'] = '2.3'\n  end\nend\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Usage\n\nAdd that near the top of your `AppDelegate.swift` to be able to use SwiftyBeaver in your whole project.\n\n```Swift\nimport SwiftyBeaver\nlet log = SwiftyBeaver.self\n\n```\n\nAt the beginning of your `AppDelegate:didFinishLaunchingWithOptions()` add the SwiftyBeaver log destinations (console, file, etc.), optionally adjust the [log format](http://docs.swiftybeaver.com/article/20-custom-format) and then you can already do the following log level calls globally:\n\n```Swift\n// add log destinations. at least one is needed!\nlet console = ConsoleDestination()  // log to Xcode Console\nlet file = FileDestination()  // log to default swiftybeaver.log file\n\n// use custom format and set console output to short time, log level \u0026 message\nconsole.format = \"$DHH:mm:ss$d $L $M\"\n// or use this for JSON output: console.format = \"$J\"\n\n// In Xcode 15, specifying the logging method as .logger to display color, subsystem, and category information in the console.(Relies on the OSLog API)\nconsole.logPrintWay = .logger(subsystem: \"Main\", category: \"UI\")\n// If you prefer not to use the OSLog API, you can use print instead.\n// console.logPrintWay = .print \n\n// add the destinations to SwiftyBeaver\nlog.addDestination(console)\nlog.addDestination(file)\n\n// Now let’s log!\nlog.verbose(\"not so important\")  // prio 1, VERBOSE in silver\nlog.debug(\"something to debug\")  // prio 2, DEBUG in green\nlog.info(\"a nice information\")   // prio 3, INFO in blue\nlog.warning(\"oh no, that won’t be good\")  // prio 4, WARNING in yellow\nlog.error(\"ouch, an error did occur!\")  // prio 5, ERROR in red\n\n// log anything!\nlog.verbose(123)\nlog.info(-123.45678)\nlog.warning(Date())\nlog.error([\"I\", \"like\", \"logs!\"])\nlog.error([\"name\": \"Mr Beaver\", \"address\": \"7 Beaver Lodge\"])\n\n// optionally add context to a log message\nconsole.format = \"$L: $M $X\"\nlog.debug(\"age\", context: 123)  // \"DEBUG: age 123\"\nlog.info(\"my data\", context: [1, \"a\", 2]) // \"INFO: my data [1, \\\"a\\\", 2]\"\n\n```\n\nAlternatively, if you are using SwiftUI, consider using the following setup:\n\n```swift\nimport SwiftyBeaver\nlet logger = SwiftyBeaver.self\n\n@main\nstruct yourApp: App {\n\n    init() {\n        let console = ConsoleDestination()\n        logger.addDestination(console)\n        // etc...\n    }\n\n    var body: some Scene {\n        WindowGroup {\n        }\n    }\n}\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Server-side Swift\n\nWe ❤️ server-side Swift 4 \u0026 5 and SwiftyBeaver support it **out-of-the-box**! Try for yourself and run SwiftyBeaver inside a Ubuntu Docker container. Just install Docker and then go to your project folder on macOS or Ubuntu and type:\n\n```shell\n# create docker image, build SwiftyBeaver and run unit tests\ndocker run --rm -it -v $PWD:/app swiftybeaver /bin/bash -c \"cd /app ; swift build ; swift test\"\n\n# optionally log into container to run Swift CLI and do more stuff\ndocker run --rm -it --privileged=true -v $PWD:/app swiftybeaver\n```\n\nBest: for the popular server-side Swift web framework [Vapor](https://github.com/vapor/vapor) you can use **[our Vapor logging provider](https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor)** which makes server logging awesome again 🙌\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## Documentation\n\n**Getting Started:**\n\n- [Features](http://docs.swiftybeaver.com/article/7-introduction)\n- [Installation](http://docs.swiftybeaver.com/article/5-installation)\n- [Basic Setup](http://docs.swiftybeaver.com/article/6-basic-setup)\n\n**Logging Destinations:**\n\n- [Colored Logging to Xcode Console](http://docs.swiftybeaver.com/article/9-log-to-xcode-console)\n- [Colored Logging to File](http://docs.swiftybeaver.com/article/10-log-to-file)\n\n**Advanced Topics:**\n\n- [Custom Format \u0026 Context](http://docs.swiftybeaver.com/article/20-custom-format)\n- [Filters](http://docs.swiftybeaver.com/article/21-filters)\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n## License\n\nSwiftyBeaver Framework is released under the [MIT License](https://github.com/SwiftyBeaver/SwiftyBeaver/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftyBeaver%2FSwiftyBeaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftyBeaver%2FSwiftyBeaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftyBeaver%2FSwiftyBeaver/lists"}