mirror of
https://github.com/apple/swift-log
synced 2026-11-23 03:44:22 +00:00
1.9.1
### Motivation:
In the latest release (1.9.0) the package manifest was split for Swift
6.0 and 6.1+. The 6.0 manifest lost the `InMemoryLogging` library
product, causing API breakage for adopters using Swift 6.0:
```diff
% diff -u <(git show 1.8.0:Package.swift) <(git show 1.9.0:Package@swift-6.0.swift)
--- /dev/fd/63 2026-01-19 10:30:21
+++ /dev/fd/62 2026-01-19 10:30:21
@@ -18,25 +18,16 @@
let package = Package(
name: "swift-log",
products: [
- .library(name: "Logging", targets: ["Logging"]),
- .library(name: "InMemoryLogging", targets: ["InMemoryLogging"]),
+ .library(name: "Logging", targets: ["Logging"])
],
targets: [
.target(
name: "Logging",
dependencies: []
),
- .target(
- name: "InMemoryLogging",
- dependencies: ["Logging"]
- ),
.testTarget(
name: "LoggingTests",
dependencies: ["Logging"]
- ),
- .testTarget(
- name: "InMemoryLoggingTests",
- dependencies: ["InMemoryLogging", "Logging"]
),
]
)
```
### Modifications:
Reinstate InMemoryLogging product in Swift 6.0 manifest
### Result:
Adopters using `InMemoryLogging` on Swift 6.0 are unbroken.
### Related issues:
Fixes #402
SwiftLog
This repository contains a logging API implementation for Swift. SwiftLog provides a unified, performant, and ergonomic logging API that can be adopted by libraries and applications across the Swift ecosystem.
- 📚 Documentation and tutorials are available on the Swift Package Index
- 🚀 Contributions are welcome, please see CONTRIBUTING.md
- 🪪 License is Apache 2.0, repeated in LICENSE.txt
- 🔒 Security issues should be reported via the process in SECURITY.md
- 🔀 Available Logging Backends: SwiftLog is an API package - you'll want to choose from the many community-maintained logging backends for production use
Quick Start
The following snippet shows how to add SwiftLog to your Swift Package:
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "YourApp",
dependencies: [
.package(url: "https://github.com/apple/swift-log", from: "1.6.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "Logging", package: "swift-log")
]
)
]
)
Then start logging:
import Logging
// Create a logger
let logger = Logger(label: "com.example.YourApp")
// Log at different levels
logger.info("Application started")
logger.warning("This is a warning")
logger.error("Something went wrong", metadata: ["error": "\(error)"])
// Add metadata for context
var requestLogger = logger
requestLogger[metadataKey: "request-id"] = "\(UUID())"
requestLogger.info("Processing request")
Available log handler backends
The community has built numerous specialized logging backends.
A great way to discover available log backend implementations is searching the
Swift Package Index
for the swift-log keyword.
Description
Mirror of github.com/apple/swift-log
3.3 MiB
0 Stars
1 Watchers
0 Forks
Languages
Swift
97.5%
CMake
2.5%