Hi everyone ![]()
I'd like to share AppLoggerKit, an open-source Swift package for structured, privacy-aware app logging. It has no third-party dependencies.
Why I built it
Most apps end up choosing between plain print/OSLog calls and a heavy remote logging SDK. I wanted something in between: logs go to the Apple unified log by default and can optionally go to local files. Sensitive data is redacted before it reaches any destination, and logs stay on the device until the user chooses to export them.
Highlights
- OSLog output with level mapping and subsystem/category filtering in Console.app
- Optional JSON Lines file logs with rotation (by size or time), retention limits, file protection and low-storage handling
- 7 levels from
tracetocritical. Messages are autoclosures, so calls below the active level cost almost nothing - Privacy by default: metadata is classified as
.private,.sensitiveor.url(...), and tokens, passwords, JWTs andBearerheaders are redacted automatically - Correlation IDs through task-local
LogContext.withCorrelationID - Search and export:
LogReaderfor paging and statistics,LogExporterfor redacted JSONL, text or ZIP output - Optional SwiftUI/UIKit viewer:
LogViewer,LiveLogConsole, and aLogExportButtonthat uses ShareLink - Testing helpers:
AppLogger.capturing()for Swift Testing - Custom destinations through a simple
LogDestinationprotocol
Quick look
let logger = AppLogger(configuration: .init(
subsystem: "com.example.app",
minimumLevel: .info,
destinations: [OSLogDestination(), FileLogDestination(configuration: .default)]
))
logger.info("Application launched", category: "lifecycle")
// SwiftUI
ContentView().appLogger(logger)
Installation (SPM)
.package(url: "https://github.com/eeshuu/AppLoggerKit.git", from: "1.0.0")
It's split into modules, so you only add what you need: AppLoggerCore, AppLoggerOSLog, AppLoggerFile, AppLoggerUI, AppLoggerTesting.
Requirements: iOS/iPadOS 16+, macOS 13+, Mac Catalyst 16+, Xcode 16 with the Swift 6 toolchain. MIT licensed.
To set expectations, it does not do remote ingestion, analytics or crash reporting. It's meant for local diagnostics.
I'd love your feedback on the API design, especially the privacy and metadata model. Issues, PRs and
s are very welcome!