Skip to content
Back to skills

Swift Logging Pro

ASecurity

Reviews Swift logging code using os.Logger for correct privacy markers, subsystem/category conventions, and appropriate log levels. Use when writing or reviewing logging code.

  • 8 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 27, 2026
ai-agentsgoswiftapiperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 27, 2026

npx -y skills add kelvinkosbab/AppBootstrapAI --skill swift-logging-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swift Logging Pro?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swift Logging Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kelvinkosbab-swift-logging-pro/badge)](https://www.skillsdirectory.com/skills/kelvinkosbab-swift-logging-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swift-logging-pro
description: Reviews Swift logging code using os.Logger for correct privacy markers, subsystem/category conventions, and appropriate log levels. Use when writing or reviewing logging code.
license: MIT
metadata:
  author: Kelvin Kosbab
  version: "1.0"
---

Review Swift logging code for correctness, privacy compliance, and consistent subsystem conventions. Report only genuine problems - do not nitpick or invent issues.

Review process:

1. Check `os.Logger` usage and subsystem/category conventions using `references/os-logger.md`.
1. Validate privacy markers on logged values using `references/privacy.md`.
1. Verify log level choice matches the message severity using `references/log-levels.md`.
1. Flag `print()` statements in production code (acceptable in tests, scripts).

If doing a partial review, load only the relevant reference files.


## Core Instructions

- Use `os.Logger` (modern API), not `OSLog` (legacy) or `print()` (no privacy, no levels, no subsystem filtering).
- Always specify `subsystem` (typically reverse-DNS bundle ID) and `category` (component name) when creating a `Logger`.
- All interpolated values default to `private` — explicitly mark with `.public` only when safe (e.g., status enums, fixed strings).
- Never log usernames, passwords, tokens, email addresses, or PII — even with `.public`.
- Use the appropriate level: `.debug` for development noise, `.info` for normal events, `.notice` for important events, `.error` for recoverable failures, `.fault` for programmer errors.
- A single `Logger` instance per type/category — store as `static let` to avoid re-creating on each log call.


## Output Format

Organize findings by file. For each issue:

1. State the file and relevant line(s).
2. Name the rule being violated.
3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

Example output:

### MyService.swift

**Line 18: Privacy violation — user identifier logged as `.public`.**

```swift
// Before
logger.info("Loaded user \(userId, privacy: .public)")

// After
logger.info("Loaded user \(userId, privacy: .private)")
```

**Line 34: Use `.error` level for recoverable failures, not `.info`.**

```swift
// Before
logger.info("Network request failed: \(error.localizedDescription)")

// After
logger.error("Network request failed: \(error.localizedDescription)")
```

**Line 45: `print()` statement in production code — replace with `Logger`.**

```swift
// Before
print("Cache miss for key \(key)")

// After
logger.debug("Cache miss for key \(key, privacy: .public)")
```

### Summary

1. **Privacy (high):** User-identifying data logged as `.public` on line 18 — change to `.private`.
2. **Severity (medium):** Recoverable failure logged at `.info` — should be `.error`.
3. **Modernization (low):** `print()` statement should use `Logger`.

End of example.


## References

- `references/os-logger.md` — `os.Logger` basics, subsystem/category conventions, instance creation patterns.
- `references/privacy.md` — `.public`, `.private`, `.sensitive` markers, redaction, what never to log.
- `references/log-levels.md` — `.debug`, `.info`, `.notice`, `.error`, `.fault` semantics, performance impact.

Files in this skill

  • SKILL.md3.2 KB
  • references/log-levels.md3.2 KB
  • references/os-logger.md2.4 KB
  • references/privacy.md3.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.