Skip to content

Commit 325d153

Browse files
committed
Remove OSLog as it doesn't support non-Apple platform
1 parent 0117196 commit 325d153

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

Examples/Examples.xcodeproj/xcshareddata/xcschemes/SlackClone.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1510"
3+
LastUpgradeVersion = "1520"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

Examples/SlackClone/Store.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class Store {
3232
channels = try await fetchChannels()
3333

3434
Task {
35-
for await status in await supabase.realtimeV2.status.values {
35+
for await status in await supabase.realtimeV2.status {
3636
self.socketConnectionStatus = String(describing: status)
3737
}
3838
}
@@ -42,7 +42,7 @@ final class Store {
4242
messagesListener = channel
4343

4444
Task {
45-
for await status in await channel.status.values {
45+
for await status in await channel.status {
4646
self.messagesListenerStatus = String(describing: status)
4747
}
4848
}
@@ -77,7 +77,7 @@ final class Store {
7777
usersListener = channel
7878

7979
Task {
80-
for await status in await channel.status.values {
80+
for await status in await channel.status {
8181
self.usersListenerStatus = String(describing: status)
8282
}
8383
}
@@ -96,7 +96,7 @@ final class Store {
9696
channelsListener = channel
9797

9898
Task {
99-
for await status in await channel.status.values {
99+
for await status in await channel.status {
100100
self.channelsListenerStatus = String(describing: status)
101101
}
102102
}

Examples/SlackClone/Supabase.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@ let decoder: JSONDecoder = {
2323
let supabase = SupabaseClient(
2424
supabaseURL: URL(string: "https://xxpemjxnvjqnjjermerd.supabase.co")!,
2525
supabaseKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4cGVtanhudmpxbmpqZXJtZXJkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDE1MTc3OTEsImV4cCI6MjAxNzA5Mzc5MX0.SLcEdwQEwZkif49WylKfQQv5ZiWRQdpDm8d2JhvBdtk",
26-
options: SupabaseClientOptions(db: .init(encoder: encoder, decoder: decoder))
26+
options: SupabaseClientOptions(
27+
db: .init(encoder: encoder, decoder: decoder),
28+
auth: SupabaseClientOptions.AuthOptions(
29+
storage: KeychainLocalStorage(service: "supabase", accessGroup: nil)
30+
)
31+
)
2732
)

Sources/Realtime/V2/RealtimeClientV2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public actor RealtimeClientV2 {
3838
}
3939
}
4040

41-
public enum Status {
41+
public enum Status: Sendable {
4242
case disconnected
4343
case connecting
4444
case connected

Sources/_Helpers/Logger.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,32 @@
77

88
import ConcurrencyExtras
99
import Foundation
10-
import OSLog
10+
11+
private struct Logger {
12+
var subsystem: String
13+
var category: String
14+
15+
func debug(
16+
_ message: @autoclosure () -> String,
17+
function: String = #function,
18+
file: String = #file,
19+
line: UInt = #line
20+
) {
21+
#if DEBUG
22+
let logLine =
23+
"[\(category)] [\(function) \(file.split(separator: "/").last!):\(line)] \(message())"
24+
print(logLine)
25+
#endif
26+
}
27+
}
1128

1229
private let _debugLoggingEnabled = LockIsolated(true)
1330
@_spi(Internal) public var debugLoggingEnabled: Bool {
1431
get { _debugLoggingEnabled.value }
1532
set { _debugLoggingEnabled.setValue(newValue) }
1633
}
1734

18-
private let logger = OSLog(subsystem: "com.supabase", category: "supabase-swift")
35+
private let logger = Logger(subsystem: "com.supabase", category: "supabase-swift")
1936
@_spi(Internal) public func debug(
2037
_ message: @autoclosure () -> String,
2138
function: String = #function,
@@ -25,8 +42,7 @@ private let logger = OSLog(subsystem: "com.supabase", category: "supabase-swift"
2542
assert(
2643
{
2744
if debugLoggingEnabled {
28-
let logLine = "[\(function) \(file.split(separator: "/").last!):\(line)] \(message())"
29-
os_log(.debug, log: logger, "%@", logLine)
45+
logger.debug(message(), function: function, file: file, line: line)
3046
}
3147

3248
return true

0 commit comments

Comments
 (0)