{"id":28522676,"url":"https://github.com/whitesmith/wslogger","last_synced_at":"2025-08-01T11:11:47.877Z","repository":{"id":56926822,"uuid":"70941064","full_name":"whitesmith/WSLogger","owner":"whitesmith","description":"An extensible iOS logger on top of OSLog","archived":false,"fork":false,"pushed_at":"2023-10-03T11:12:52.000Z","size":118,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T09:39:53.573Z","etag":null,"topics":["oslog"],"latest_commit_sha":null,"homepage":"","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/whitesmith.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":"2016-10-14T19:28:12.000Z","updated_at":"2023-10-20T08:49:14.000Z","dependencies_parsed_at":"2022-08-20T23:30:34.765Z","dependency_job_id":null,"html_url":"https://github.com/whitesmith/WSLogger","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/whitesmith/WSLogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesmith%2FWSLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesmith%2FWSLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesmith%2FWSLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesmith%2FWSLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitesmith","download_url":"https://codeload.github.com/whitesmith/WSLogger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesmith%2FWSLogger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263838636,"owners_count":23518124,"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":["oslog"],"created_at":"2025-06-09T09:31:00.345Z","updated_at":"2025-07-06T02:31:23.454Z","avatar_url":"https://github.com/whitesmith.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WSLogger\n\n[![SPM Compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg)](https://www.swift.org/package-manager/)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/WSLogger.svg)](https://cocoapods.org/pods/WSLogger)\n[![Platforms](https://img.shields.io/badge/platforms-iOS%2C%20macOS%2C%20watchOS%2C%20tvOS%2C%20visionOS-lightgrey.svg)](http://www.apple.com/ios/)\n\nAn extensible iOS logger on top of [OSLog](https://developer.apple.com/documentation/os/oslog) - the replacement for `print`, and `NSLog` and Apple’s recommended way of logging.\n\n\u003e OSLog has a low-performance overhead and is archived on the device for later retrieval. You can read logs using the external Console app or benefit from structured logging directly inside Xcode 15. Altogether, obtaining structured logging via OSLog is far better than using print statements.\n\n## Usage\n\nAn example of expanding all log entries using `WSLoggable`:\n\n``` swift\nimport WSLogger\n\nextension WSLoggable {\n    func log(_ message: String, level: WSLogLevel = .debug, customAttributes: [String : Any]? = nil, className: String = \"\", fileName: NSString = #file, line: Int = #line, function: String = #function) {\n        // Log internally\n        let text = WSLogger.shared.log(message, level: level, customAttributes: customAttributes, className: String(describing: type(of: self)), fileName: fileName, line: line, function: function)\n        // Log remotely using `text`.\n        // Sentry, DataDog, LogEntries, etc.\n    }\n}\n```\n\nYou can add a `typealias` to avoid importing the `WSLogger` on every file:\n\n``` swift\ntypealias Loggable = WSLoggable\ntypealias LoggerOptions = WSLoggerOptions\ntypealias LogLevel = WSLogLevel\n```\n\nThen use the protocol `Loggable` where you want. The function `log` will be accessible:\n\n``` swift\nstruct WSTableViewCell: Loggable {\n    func configure(viewModel: ViewModel) {\n        log(\"Bind model data with views\")\n        ...\n    }\n}\n```\n\nIt is possible to change the log level with `LoggerOptions.defaultLevel` property. For example, if `LoggerOptions.defaultLevel ` is `debug` then all the `verbose` entries will be ignored.\n\nYou can add `LoggerOptions.defaultLevel = .none` to discard any log events on your test suite. It's also possible ignoring classes with `Logger.shared.ignoreClass(WSTableViewCell)`.\n\nYou can execute those operations in debug mode as well. Just write in the console `expr -- Logger.shared.ignoreClass(WSTableViewCell)`.\n\n\n### Extend the log mechanism: example using [LogEntries](https://docs.logentries.com/docs/ios)\n\nYou can extend the log mechanism as you want. For example, if you want to access the log entries online:\n\n![LogEntries dashboard](https://github.com/whitesmith/WSLogger/blob/6b1e61e3c82e41b2fd0596cf6b16d32c9df32f20/Example/LogEntries.png?raw=true)\n\n``` swift\nimport Foundation\nimport WSLogger\nimport LogEntries //LogEntries iOS lib\n\npublic enum LoggerCategory: String, CaseIterable {\n    case global\n    case network\n    case ui\n    case cache\n}\n\nprivate var loggerQueue: DispatchQueue!\nprivate var logger: WSLogger\u003cLoggerCategory\u003e!\n\nfunc loggerSetup() {\n    LoggerOptions.defaultLevel = .verbose\n    loggerQueue = DispatchQueue(label: \"Logger\", qos: .utility)\n    logger = WSLogger\u003cLoggerCategory\u003e()\n    logger.traceFile = true\n    logger.traceMethod = true\n    // LogEntries\n    LELog.sharedInstance().token = \"XXXX-XXX-XXX-XXXX\"\n}\n\nextension WSLoggable {\n    func log(_ message: String, level: WSLogLevel = .debug, customAttributes: [String : Any]? = nil, className: String = \"\", fileName: NSString = #file, line: Int = #line, function: String = #function) {\n    loggerQueue.async {\n        // Log internally\n        let text = logger.log(message, level: level, customAttributes: customAttributes, className: String(describing: type(of: self)), fileName: fileName, line: line, function: function)\n        // Log remotely\n        LELog.sharedInstance().log(text as NSObject)\n    }\n}\n```\n\nThe complete example is available [here](https://github.com/whitesmith/WSLogger/tree/master/Example).\n\n\n## Installation\n\n#### \u003cimg src=\"https://raw.githubusercontent.com/ricardopereira/resources/master/img/cocoapods.png\" width=\"24\" height=\"24\"\u003e [CocoaPods]\n\n[CocoaPods]: http://cocoapods.org\n\nTo install it, simply add the following line to your **Podfile**:\n\n```ruby\npod 'WSLogger'\n```\n\nYou will also need to make sure you're opting into using frameworks:\n\n```ruby\nuse_frameworks!\n```\n\nThen run `pod install` with CocoaPods 1.0 or newer.\n\n#### Manually\n\nDownload all the source files and drop them into your project.\n\n## Requirements\n\n* iOS 12.0+\n* Xcode 13 (Swift 5.0)\n\n# Contributing\n\nThe best way to contribute is by submitting a pull request. We'll do our best to respond to your patch as soon as possible. You can also submit a [new GitHub issue](https://github.com/whitesmith/WSLogger/issues/new) if you find bugs or have questions. :octocat:\n\n# Credits\n![Whitesmith](http://i.imgur.com/Si2l3kd.png)\n\nCheckout the excelent topic on [Logging in Swift](http://merowing.info/2016/07/logging-in-swift/) from [Krzysztof Zabłocki](https://twitter.com/merowing_).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitesmith%2Fwslogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitesmith%2Fwslogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitesmith%2Fwslogger/lists"}