Repository navigation
SwiftMoLogger 4.3.0
Per-value privacy in log messages, opt-in network bodies with Copy as cURL, and MetricKit metric payloads with every diagnostic kind. Additive; no API changes.
Added
- Per-value privacy. Mark one value in a message instead of hiding the whole message, as with
os.Logger:log.info("Signed in \(email, privacy: .private)")logsSigned in <private>.LogPrivacyhas.public,.private,.sensitive(never revealed) and a.hashmask for a stable<hash:…>. Values are replaced before theLogEntryis created, so no engine sees them;registry.revealsPrivateValues = trueshows.privatevalues in DEBUG builds. TheLogMessageoverloads sit alongside theStringones, so existing call sites are unchanged, and filtered calls still don't build the message. (#21) - Network bodies and cURL export.
NetworkLogger(…, bodies: .debugOnly(maxBytes:))captures request bodies (fromhttpBody) and response bodies (fromurlSession(_:dataTask:didReceive:)) intoNetworkEvent.requestBody/responseBody. Capture is off by default,.debugOnlycaptures nothing in release builds, and.always(maxBytes:)is the explicit opt-in for every build. Bodies go through aRedactor, are cut atmaxBytesand marked as truncated, are kept only for text content types, and never go into log entries.NetworkEvent.requestHeadersrecords the redacted headers, andNetworkEvent.curlCommandbuilds a shell-quotedcurlcommand from the redacted URL, headers and body. The Hub's request detail shows headers and bodies and has a Copy as cURL button where the platform has a pasteboard.NetworkLoggeris now aURLSessionDataDelegate; with capture off, the new callback returns at once. (#13) - MetricKit metric payloads. On iOS,
MetricKitCrashReporternow logs each dailyMXMetricPayloadas one.infoentry tagged.performance: time to first draw (plus prewarmed launches), resume time and hang time as count, average, p50 and p95 from MetricKit's histograms, peak and average suspended memory, disk writes, CPU time, memory-limit and jetsam exits, the app version and the period the payload covers. (#17) - More diagnostics. CPU exceptions, disk-write exceptions and app-launch diagnostics (iOS 16 / macOS 13) are logged as
.warningentries tagged.performance, next to crashes and hangs. Crash entries add the exception and signal names, the termination reason, an uncaught Objective-C exception's name and message (iOS 17), a hint and the binaries on the crashing thread. (#17) MetricPayloadSummaryandDiagnosticPayloadSummaryparse a payload'sjsonRepresentation(), andMetricKitPayloadLoggerlogs them, so payloads recorded on a device can be replayed in tests without buildingMXobjects. Durations are in milliseconds and sizes in bytes. (#17)MetricPayloadSource, the port the reporter reads payloads from.MXMetricManagerPayloadSourceis the default;MetricKitCrashReporter(logger:source:)takes any other, such as a replay of recorded JSON. (#17)
Changed
- Crash pattern hints and the binaries on the crashing thread are now metadata (
hint,binaries) on the crash entry, instead of separate log entries. Binaries come from the attributed thread's whole call stack, not just its root frames. (#17) - With a custom source,
crashReportDelegateandhangReportDelegatearen't called, because they take MetricKit objects that a JSON source doesn't have. The default source calls them as before.
Notes
- The iOS 27
MetricManagerAPI isn't adopted yet. The reporter doesn't use the async API yet: its exact Swift shape couldn't be checked against the iOS 27 SDK, and a guessed signature would break the Xcode 27 build. It will be added as anotherMetricPayloadSource, behind#if compiler(>=6.4)and@available(iOS 27, *), so the reporter, the summaries and the logged entries stay the same.MXMetricManagerremains the source until then.
Install
.package(url: "https://github.com/MoElnaggar14/SwiftMoLogger.git", from: "4.3.0")