fix(log): use Swift OSLog instead of oslog Rust binding (#262)

This commit is contained in:
Lucas Fernandes Nogueira
2023-02-23 09:17:15 -08:00
committed by GitHub
parent 22f987bf24
commit 961602bd1b
8 changed files with 117 additions and 89 deletions
+11
View File
@@ -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
+31
View File
@@ -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")
]
)
+3
View File
@@ -0,0 +1,3 @@
# Log
Exposes a function log a message using the OSLog API.
+13
View File
@@ -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
}
}