Skip to content

Commit

Permalink
Add Sendable to SupabaseLogMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Mar 19, 2024
1 parent bd7d06e commit e853de4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Examples/SlackClone/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ final class LogStore: SupabaseLogger {

static let shared = LogStore()

@MainActor
var messages: [SupabaseLogMessage] = []

func log(message: SupabaseLogMessage) {
messages.append(message)
Task {
await add(message: message)
}

lock.withLock {
if loggers[message.system] == nil {
loggers[message.system] = Logger(
Expand All @@ -42,4 +46,9 @@ final class LogStore: SupabaseLogger {
}
}
}

@MainActor
private func add(message: SupabaseLogMessage) {
messages.insert(message, at: 0)
}
}
2 changes: 1 addition & 1 deletion Examples/SlackClone/Supabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let decoder: JSONDecoder = {
}()

let supabase = SupabaseClient(
supabaseURL: URL(string: "http://192.168.0.6:54321")!,
supabaseURL: URL(string: "http://localhost:54321")!,
supabaseKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
options: SupabaseClientOptions(
db: .init(encoder: encoder, decoder: decoder),
Expand Down
2 changes: 1 addition & 1 deletion Sources/_Helpers/SupabaseLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum SupabaseLogLevel: Int, Codable, CustomStringConvertible, Sendable {
}
}

public struct SupabaseLogMessage: Codable, CustomStringConvertible {
public struct SupabaseLogMessage: Codable, CustomStringConvertible, Sendable {
public let system: String
public let level: SupabaseLogLevel
public let message: String
Expand Down

0 comments on commit e853de4

Please sign in to comment.