Skip to content

Commit

Permalink
Change dsn to nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Feb 16, 2024
1 parent 74b1c44 commit 18c5dcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 1 addition & 6 deletions Sources/ExtendedLogging/SentryLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct SentryLogger: LogHandler {
private var logFormatter: LogFormatter

public init(label: String,
dsn: String,
dsn: String?,
level: Logger.Level = .debug,
metadata: Logger.Metadata = [:]) {
self.label = label
Expand Down Expand Up @@ -52,9 +52,4 @@ public struct SentryLogger: LogHandler {
self.metadata[metadataKey] = newValue
}
}

// for testing
public func wait() -> Void {
// fileWriter.wait()
}
}
14 changes: 9 additions & 5 deletions Sources/ExtendedLogging/SentryWriter.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import Foundation

internal class SentryWriter {
private let dsn: String;
private let dsn: String?
private let requestQueue = DispatchQueue.init(label: "SentryWriter", qos: .utility)

init(dsn: String) {
init(dsn: String?) {
self.dsn = dsn
}

func write(message: Data?) {
guard let sentryDsn = self.dsn else {
return
}

guard let data = message else {
print("[SentryWriter] Logged message cannot be nil.")
return
}

guard let url = self.convertToUrl() else {
guard let url = self.convertToUrl(sentryDsn: sentryDsn) else {
print("[SentryWriter] Cannot parse Sentry DSN url.")
return
}
Expand All @@ -33,8 +37,8 @@ internal class SentryWriter {
}
}

private func convertToUrl() -> URL? {
let dsnUrl = URLComponents(string: self.dsn)
private func convertToUrl(sentryDsn: String) -> URL? {
let dsnUrl = URLComponents(string: sentryDsn)

guard let scheme = dsnUrl?.scheme else {
return nil
Expand Down

0 comments on commit 18c5dcc

Please sign in to comment.