Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Logging API for Swift

License

NotificationsYou must be signed in to change notification settings

apple/swift-log

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.

Quick Start

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")

Available log handler backends

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.


[8]ページ先頭

©2009-2025 Movatter.jp