-
Couldn't load subscription status.
- Fork 225
[V5] Integrate StreamCore and its Logger #3845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // | ||
|
|
||
| import Foundation | ||
| import StreamCore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inlinable code requires import
Generated by 🚫 Danger |
Public Interface- public struct LogSubsystem: OptionSet, Sendable
-
- public let rawValue: Int
- public static let all: LogSubsystem
- public static let other
- public static let database
- public static let httpRequests
- public static let webSocket
- public static let offlineSupport
- public static let authentication
- public static let audioPlayback
- public static let audioRecording
-
-
- public init(rawValue: Int)
- public extension LogDestination
- public class PrefixLogFormatter: LogFormatter
-
- public init(prefixes: [LogLevel: String])
-
-
- public func format(logDetails: LogDetails,message: String)-> String
- public class Logger: @unchecked Sendable
-
- public let identifier: String
- public var destinations: [LogDestination]
-
-
- public init(identifier: String = "",destinations: [LogDestination] = [])
-
-
- public func callAsFunction(_ level: LogLevel,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line,message: @autoclosure () -> Any,subsystems: LogSubsystem = .other)
- public func log(_ level: LogLevel,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line,message: @autoclosure () -> Any,subsystems: LogSubsystem = .other)
- public func info(_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public func debug(_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public func warning(_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public func error(_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public func assert(_ condition: @autoclosure () -> Bool,_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public func assertionFailure(_ message: @autoclosure () -> Any,subsystems: LogSubsystem = .other,functionName: StaticString = #function,fileName: StaticString = #file,lineNumber: UInt = #line)
- public enum LogConfig
-
- public nonisolated static var identifier
- public nonisolated static var level: LogLevel
- public nonisolated static var dateFormatter: DateFormatter
- public nonisolated static var formatters
- public nonisolated static var showDate
- public nonisolated static var showLevel
- public nonisolated static var showIdentifier
- public nonisolated static var showThreadName
- public nonisolated static var showFileName
- public nonisolated static var showLineNumber
- public nonisolated static var showFunctionName
- public nonisolated static var subsystems: LogSubsystem
- public nonisolated static var destinationTypes: [LogDestination.Type]
- public static var destinations: [LogDestination]
- public static var logger: Logger
- public struct LogDetails
-
- public let loggerIdentifier: String
- public let level: LogLevel
- public let date: Date
- public let message: String
- public let threadName: String
- public let functionName: StaticString
- public let fileName: StaticString
- public let lineNumber: UInt
- public enum LogLevel: Int, Sendable
-
- case debug = 0
- case info
- case warning
- case error
- public protocol LogDestination: Sendable
- public class ConsoleLogDestination: BaseLogDestination, @unchecked Sendable
-
- override open func write(message: String)
- open class BaseLogDestination: LogDestination, @unchecked Sendable
-
- open var identifier: String
- open var level: LogLevel
- open var subsystems: LogSubsystem
- open var dateFormatter: DateFormatter
- open var formatters: [LogFormatter]
- open var showDate: Bool
- open var showLevel: Bool
- open var showIdentifier: Bool
- open var showThreadName: Bool
- open var showFileName: Bool
- open var showLineNumber: Bool
- open var showFunctionName: Bool
-
-
- public required init(identifier: String,level: LogLevel,subsystems: LogSubsystem,showDate: Bool,dateFormatter: DateFormatter,formatters: [LogFormatter],showLevel: Bool,showIdentifier: Bool,showThreadName: Bool,showFileName: Bool,showLineNumber: Bool,showFunctionName: Bool)
-
-
- open func isEnabled(level: LogLevel,subsystems: LogSubsystem)-> Bool
- open func process(logDetails: LogDetails)
- open func applyFormatters(logDetails: LogDetails,message: String)-> String
- open func write(message: String)
- public protocol LogFormatter
|
StreamChat.xcodeproj/project.pbxproj
Outdated
| isa = XCRemoteSwiftPackageReference; | ||
| repositoryURL = "https://github.com/GetStream/stream-core-swift"; | ||
| requirement = { | ||
| branch = "restructure-for-chat"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it after releasing StreamCore
| let spyState = SpyState() | ||
| var originalLogger: Logger? | ||
| @Atomic var failedAsserts: Int = 0 | ||
| @StreamCore.Atomic var failedAsserts: Int = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StreamCore also has Atomic, will get cleaned up in a separate PR which replaces Atomic
Package.swift
Outdated
| ], | ||
| dependencies: [ | ||
| .package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.0.0"), | ||
| .package(url: "https://github.com/GetStream/stream-core-swift.git", exact: "0.3.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update before merging
SDK Size
|
| } catch { | ||
| if error is ClientError.IgnoredEventType { | ||
| log.info("Skipping unsupported event type: \($0.eventType)") | ||
| StreamChat.log.info("Skipping unsupported event type: \($0.eventType)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't figure it out. There is no separate log instance method.
SwiftCompile normal arm64 /Users/tvahter/Developer/stream-chat-swift/Sources/StreamChat/WebSocketClient/Events/EventPayload.swift (in target 'StreamChat' from project 'StreamChat')
cd /Users/tvahter/Developer/stream-chat-swift
/Users/tvahter/Developer/stream-chat-swift/Sources/StreamChat/WebSocketClient/Events/EventPayload.swift:276:21: error: use of 'log' refers to instance method rather than var 'log' in module 'StreamCore'
log.info("Skipping unsupported event type: \($0.eventType)")
^
/Users/tvahter/Developer/stream-chat-swift/Sources/StreamChat/WebSocketClient/Events/EventPayload.swift:276:21: note: use 'StreamCore.' to reference the var in module 'StreamCore'
log.info("Skipping unsupported event type: \($0.eventType)")
^
StreamCore.
StreamCore.log:1:12: note: 'log' declared here
public var log: StreamCore.Logger { get }
^
|




🔗 Issue Links
Related: IOS-991
🎯 Goal
Integrate StreamCore and its Logger
📝 Summary
Initial PR for bringing in StreamCore with a small change which replaces the Logger
🛠 Implementation
🎨 Showcase
🧪 Manual Testing Notes
☑️ Contributor Checklist
docs-contentrepo