Skip to content

Conversation

@laevandus
Copy link
Contributor

🔗 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

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@laevandus laevandus requested a review from a team as a code owner October 16, 2025 06:31
@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v5-stream-core

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

//

import Foundation
import StreamCore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlinable code requires import

@github-actions
Copy link

1 Warning
⚠️ Big PR
1 Message
📖 There seems to be app changes but CHANGELOG wasn't modified.
Please include an entry if the PR includes user-facing changes.
You can find it at CHANGELOG.md.

Generated by 🚫 Danger

@github-actions
Copy link

github-actions bot commented Oct 16, 2025

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

isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/GetStream/stream-core-swift";
requirement = {
branch = "restructure-for-chat";
Copy link
Contributor Author

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
Copy link
Contributor Author

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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update before merging

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Oct 16, 2025

SDK Size

title develop branch diff status
StreamChat 8.26 MB 8.38 MB +115 KB 🟢
StreamChatUI 4.89 MB 5.05 MB +161 KB 🟢

} catch {
if error is ClientError.IgnoredEventType {
log.info("Skipping unsupported event type: \($0.eventType)")
StreamChat.log.info("Skipping unsupported event type: \($0.eventType)")
Copy link
Contributor

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?

Copy link
Contributor Author

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 }
           ^

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@laevandus laevandus merged commit e3e273f into v5 Oct 21, 2025
13 of 14 checks passed
@laevandus laevandus deleted the v5-stream-core branch October 21, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants