laconicman/oslogloggingmiddleware
A logging middleware package for Swift OpenAPI Generator/Runtime that provides detailed request and response logging capabilities. Uses system OSLog.
Features
- 📝 Comprehensive request and response logging
- ⚡️ Pretty printed
- 🔧 Configurable logging levels and formats
- 🎯 Non-intrusive middleware design
Installation
Swift Package Manager
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/laconicman/OSLogLoggingMiddleware.git", from: "1.1.1")
]Then add the dependency to your target:
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "OSLogLoggingMiddleware", package: "OSLogLoggingMiddleware")
]
)
]Requirements
Apple platforms only (macOS 11+, iOS 14+, tvOS 14+, watchOS 7+, visionOS 1+) — the package is OSLog-backed, and compiles to an empty module elsewhere. It depends on OpenAPIRuntime and HTTPTypes only: bring your own transport (URLSession, AsyncHTTPClient, Hummingbird…), which also makes it usable server-side.
Usage
Basic Setup
import OpenAPIURLSession
import OSLogLoggingMiddleware
func makeClient(serverURL: URL) -> Client {
Client(
serverURL: serverURL,
transport: URLSessionTransport(),
middlewares: [OSLogLoggingMiddleware()]
)
}The design decisions behind this package — transport-free dependency set, privacy defaults, platform floor — are documented and authoritative in the rendered Design article (Sources/OSLogLoggingMiddleware/OSLogLoggingMiddleware.docc/Design.md).
Contributing
Contributions are welcome!
This is helper package for the following
- swift-openapi-generator - The main Swift OpenAPI Generator project
- swift-openapi-runtime - Runtime library for Swift OpenAPI Generator
License
This project is licensed under the Apache License 2.0.
Package Metadata
Repository: laconicman/oslogloggingmiddleware
Default branch: main
README: readme.md