Skip to content

Commit

Permalink
moved run time warning log to logging client
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaysubra committed Aug 22, 2024
1 parent be5f2f8 commit 5ec484d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
23 changes: 0 additions & 23 deletions Sources/KlaviyoCore/KlaviyoEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import AnyCodable
import Combine
import Foundation
import UIKit
#if canImport(os)
import os
#endif

public var environment = KlaviyoEnvironment.production

Expand Down Expand Up @@ -186,23 +183,3 @@ public struct DataDecoder {
try jsonDecoder.decode(T.self, from: data)
}
}

@usableFromInline
@inline(__always)
func runtimeWarn(
_ message: @autoclosure () -> String,
category: String? = __klaviyoSwiftName,
file: StaticString? = nil,
line: UInt? = nil) {
#if DEBUG
let message = message()
let category = category ?? "Runtime Warning"
#if canImport(os)
os_log(
.fault,
log: OSLog(subsystem: "com.apple.runtime-issues", category: category),
"%@",
message)
#endif
#endif
}
22 changes: 22 additions & 0 deletions Sources/KlaviyoCore/Utils/LoggerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//

import Foundation
#if canImport(os)
import os
#endif

public struct LoggerClient {
public init(error: @escaping (String) -> Void) {
Expand All @@ -16,3 +18,23 @@ public struct LoggerClient {
public var error: (String) -> Void
public static let production = Self(error: { message in os_log("%{public}s", type: .error, message) })
}

@usableFromInline
@inline(__always)
func runtimeWarn(
_ message: @autoclosure () -> String,
category: String? = __klaviyoSwiftName,
file: StaticString? = nil,
line: UInt? = nil) {
#if DEBUG
let message = message()
let category = category ?? "Runtime Warning"
#if canImport(os)
os_log(
.fault,
log: OSLog(subsystem: "com.apple.runtime-issues", category: category),
"%@",
message)
#endif
#endif
}

0 comments on commit 5ec484d

Please sign in to comment.