Skip to content

Repository files navigation

logo

AMLogger

A structured, privacy-aware logging library for Apple platforms, backed by OSLog and SwiftData.

Overview

AMLogger provides structured logging with built-in persistence and a full console UI. It replaces traditional logging solutions with a zero-dependency package that stores logs on-device using SwiftData, supports privacy-annotated interpolation, and includes a complete log viewer.

Features

  • OSLog + SwiftData — immediate console output via os.Logger, persistent storage via SwiftData
  • Privacy controls — three levels (public, private, hashed) for sensitive values
  • Actor-based buffering — async writes never block the calling thread
  • Built-in console UI — filterable, searchable log viewer with session management
  • Network logging — structured HTTP request/response snapshots with body preview
  • Typed metadata.plain key-value pairs or .network structured data
  • Session tracking — logs grouped by app launch
  • Store rotation — automatic count-based and size-based cleanup
  • Configurable colors — override level colors to match your app's design
  • Zero dependencies — no third-party packages

Requirements

  • iOS 17+ / macOS 14+ / tvOS 17+ / watchOS 10+ / visionOS 2+
  • Swift 6.0+
  • Xcode 16+

Breaking Changes in 2.0

Version 2.0 is a major release. If you are upgrading from 1.x, note:

  • Pulse has been removed. AMLogger is now a zero-dependency package. The Pulse/PulseUI and swift-docc-plugin dependencies are gone.
  • New SwiftData persistence layer. Logs are stored on-device via SwiftData, replacing the previous Pulse-backed storage.
  • No data migration. Logs stored by 1.x through Pulse are not migrated and are not recoverable through AMLogger. 2.0 starts with a fresh store on first launch.
  • Restructured public API. Review your call sites against the updated Quick Start.

Full details in the 2.0.0 changelog.

Installation

Add AMLogger via Swift Package Manager:

.package(url: "https://github.com/andrealufino/AMLogger", from: "2.0.0")

Quick Start

import AMLogger

// Use predefined loggers
AMLogger.general.info("App launched")
AMLogger.network.debug("GET /api/users — 200 OK")
AMLogger.auth.warning("Token expiring in 60s")
AMLogger.database.error("Constraint violation: \(error)")

// Privacy-annotated values
AMLogger.auth.info("User: \(email, privacy: .hashed)")
AMLogger.auth.debug("Token: \(token, privacy: .private)")

// Metadata
AMLogger.api.info("Response", metadata: .plain([
    "status": .public("200"),
    "token":  .private("Bearer secret"),
]))

Console UI

Present the built-in console as a sheet:

.sheet(isPresented: $showConsole) {
    AMLoggerConsoleView()
        .withLoggerContainer()
}

Documentation

Full documentation is available in docs/Documentation.md.

License

AMLogger is available under the MIT license.

Releases

Packages

Contributors

Languages