谷歌云 Swift 版错误报告

此软件包提供了一个 Swift 实现,用于在 Google 云平台上进行错误报告。

示例用法

import GoogleCloudErrorReporting

let errorReportingService = ErrorReportingService()
Task { try await errorReportingService.run() }

try await service.report(
    date: Date(),
    message: "Error doing testing",
    source: "error-reporting.test",
    file: #file,
    function: #function,
    line: #line
)

这将自动使用 Google 云进行身份验证,并将错误发送到 Cloud Error Reporting

请参阅 Google Cloud Auth for Swift 以了解支持的身份验证方法。

日志处理程序

还有一个日志处理程序,可以与 SwiftLog 一起使用。

import Logging
import GoogleCloudErrorReporting

let errorReportingService = ErrorReportingService()
Task { try await errorReportingService.run() }

LoggingSystem.bootstrap { label in
    ErrorReportingLogHandler(service: errorReportingService, label: label)
}