mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-24 17:20:51 +02:00
fix(log): use Swift OSLog instead of oslog Rust binding (#262)
This commit is contained in:
committed by
GitHub
parent
22f987bf24
commit
961602bd1b
@@ -0,0 +1,11 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
Package.resolved
|
||||
/tauri-api
|
||||
@@ -0,0 +1,31 @@
|
||||
// swift-tools-version:5.7
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "tauri-plugin-log",
|
||||
platforms: [
|
||||
.iOS(.v11),
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "tauri-plugin-log",
|
||||
type: .static,
|
||||
targets: ["tauri-plugin-log"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "Tauri", path: "tauri-api")
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "tauri-plugin-log",
|
||||
dependencies: [
|
||||
.byName(name: "Tauri")
|
||||
],
|
||||
path: "Sources")
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Log
|
||||
|
||||
Exposes a function log a message using the OSLog API.
|
||||
@@ -0,0 +1,13 @@
|
||||
import UIKit
|
||||
import Tauri
|
||||
import SwiftRs
|
||||
|
||||
@_cdecl("tauri_log")
|
||||
func log(level: Int, message: UnsafePointer<SRString>) {
|
||||
switch level {
|
||||
case 1: Logger.debug(message.pointee.to_string())
|
||||
case 2: Logger.info(message.pointee.to_string())
|
||||
case 3: Logger.error(message.pointee.to_string())
|
||||
default: break
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user