OSLogViewer

OSLogViewer 用于查看您的应用程序的 OS_Log 历史记录。它是一个 SwiftUI 视图,可以在您的应用程序中使用,以查看和导出您的日志。

Swift Package Manager License

主要特性

需求

安装

使用 Swift Package Manager 安装

dependencies: [
    .package(url: "https://github.com/0xWDG/OSLogViewer.git", branch: "main"),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "OSLogViewer", package: "OSLogViewer"),
    ]),
]

并导入它

import OSLogViewer

使用方法

快速使用

import OSLogViewer

NavigationLink {
    // Default configuration
    // uses your app's bundle identifier as subsystem
    // and shows all logs from the last hour.
    OSLogViewer()
} label: {
    Text("View logs")
}

自定义使用

自定义子系统

import OSLogViewer

OSLogViewer(
    subsystem: "nl.wesleydegroot.exampleapp",
)

自定义时间

import OSLogViewer

OSLogViewer(
    since: Date().addingTimeInterval(-7200) // 2 hours
)

自定义子系统和时间

import OSLogViewer

OSLogViewer(
    subsystem: "nl.wesleydegroot.exampleapp",
    since: Date().addingTimeInterval(-7200) // 2 hours
)

屏幕截图

导出示例

This is the OSLog archive for exampleapp
Generated on 2/6/2024, 11:53
Generator https://github.com/0xWDG/OSLogViewer

Info message
ℹ️ 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

Error message
❗ 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

Error message
❗ 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

Critical message
‼️ 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

Log message
🔔 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

Log message
🔔 2/6/2024, 11:53 🏛️ exampleapp ⚙️ nl.wesleydegroot.exampleapp 🌐 myCategory

更新日志

联系方式

🦋 @0xWDG 🐘 mastodon.social/@0xWDG 🐦 @0xWDG 🧵 @0xWDG 🌐 wesleydegroot.nl 🤖 Discord

有兴趣了解更多关于 Swift 的信息吗? 查看我的博客