- Notifications
You must be signed in to change notification settings - Fork333
apple/swift-log
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository contains a logging API implementation for Swift.SwiftLog provides a unified, performant, and ergonomic logging API that can beadopted by libraries and applications across the Swift ecosystem.
- 📚Documentation andtutorials are available on theSwift Package Index
- 🚀Contributions are welcome, please seeCONTRIBUTING.md
- 🪪License is Apache 2.0, repeated inLICENSE.txt
- 🔒Security issues should be reported via the process inSECURITY.md
- 🔀Available Logging Backends: SwiftLog is an API package - you'll want tochoose from the manycommunity-maintained logging backends for production use
The following snippet shows how to add SwiftLog to your Swift Package:
// swift-tools-version: 6.1import PackageDescriptionletpackage=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 loggerletlogger=Logger(label:"com.example.YourApp")// Log at different levelslogger.info("Application started")logger.warning("This is a warning")logger.error("Something went wrong", metadata:["error":"\(error)"])// Add metadata for contextvarrequestLogger= loggerrequestLogger[metadataKey:"request-id"]="\(UUID())"requestLogger.info("Processing request")
The community has built numerous specialized logging backends.
A great way to discover available log backend implementations is searching theSwift Package Indexfor theswift-log keyword.
About
A Logging API for Swift
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.