Skip to content

Commit

Permalink
Remove OSLog as it doesn't support non-Apple platform
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Jan 12, 2024
1 parent 0117196 commit 325d153
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 4 additions & 4 deletions Examples/SlackClone/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Store {
channels = try await fetchChannels()

Task {
for await status in await supabase.realtimeV2.status.values {
for await status in await supabase.realtimeV2.status {
self.socketConnectionStatus = String(describing: status)
}
}
Expand All @@ -42,7 +42,7 @@ final class Store {
messagesListener = channel

Task {
for await status in await channel.status.values {
for await status in await channel.status {
self.messagesListenerStatus = String(describing: status)
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ final class Store {
usersListener = channel

Task {
for await status in await channel.status.values {
for await status in await channel.status {
self.usersListenerStatus = String(describing: status)
}
}
Expand All @@ -96,7 +96,7 @@ final class Store {
channelsListener = channel

Task {
for await status in await channel.status.values {
for await status in await channel.status {
self.channelsListenerStatus = String(describing: status)
}
}
Expand Down
7 changes: 6 additions & 1 deletion Examples/SlackClone/Supabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ let decoder: JSONDecoder = {
let supabase = SupabaseClient(
supabaseURL: URL(string: "https://xxpemjxnvjqnjjermerd.supabase.co")!,
supabaseKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inh4cGVtanhudmpxbmpqZXJtZXJkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDE1MTc3OTEsImV4cCI6MjAxNzA5Mzc5MX0.SLcEdwQEwZkif49WylKfQQv5ZiWRQdpDm8d2JhvBdtk",
options: SupabaseClientOptions(db: .init(encoder: encoder, decoder: decoder))
options: SupabaseClientOptions(
db: .init(encoder: encoder, decoder: decoder),
auth: SupabaseClientOptions.AuthOptions(
storage: KeychainLocalStorage(service: "supabase", accessGroup: nil)
)
)
)
2 changes: 1 addition & 1 deletion Sources/Realtime/V2/RealtimeClientV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public actor RealtimeClientV2 {
}
}

public enum Status {
public enum Status: Sendable {
case disconnected
case connecting
case connected
Expand Down
24 changes: 20 additions & 4 deletions Sources/_Helpers/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,32 @@

import ConcurrencyExtras
import Foundation
import OSLog

private struct Logger {
var subsystem: String
var category: String

func debug(
_ message: @autoclosure () -> String,
function: String = #function,
file: String = #file,
line: UInt = #line
) {
#if DEBUG
let logLine =
"[\(category)] [\(function) \(file.split(separator: "/").last!):\(line)] \(message())"
print(logLine)
#endif
}
}

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

private let logger = OSLog(subsystem: "com.supabase", category: "supabase-swift")
private let logger = Logger(subsystem: "com.supabase", category: "supabase-swift")
@_spi(Internal) public func debug(
_ message: @autoclosure () -> String,
function: String = #function,
Expand All @@ -25,8 +42,7 @@ private let logger = OSLog(subsystem: "com.supabase", category: "supabase-swift"
assert(
{
if debugLoggingEnabled {
let logLine = "[\(function) \(file.split(separator: "/").last!):\(line)] \(message())"
os_log(.debug, log: logger, "%@", logLine)
logger.debug(message(), function: function, file: file, line: line)
}

return true
Expand Down

0 comments on commit 325d153

Please sign in to comment.