Skip to content
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

Fix the thread name printed by the Logger #3382

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

### 🔄 Changed
## StreamChat
### 🐞 Fixed
- Fix Logger printing the incorrect thread name [#3382](https://github.com/GetStream/stream-chat-swift/pull/3382)

# [4.62.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.62.0)
_August 15, 2024_
Expand Down
6 changes: 5 additions & 1 deletion Sources/StreamChat/Utils/Logger/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ public class Logger {
// it is important the closure is performed in the managedObjectContext's thread.
let messageString = String(describing: message())

// Read the thread name before dispatching the log to the desired destinations,
// so that we have the name of the thread that actually initiated the log.
let threadName = threadName

loggerQueue.async { [weak self] in
guard let self = self else { return }

Expand All @@ -298,7 +302,7 @@ public class Logger {
level: level,
date: Date(),
message: messageString,
threadName: self.threadName,
threadName: threadName,
functionName: functionName,
fileName: fileName,
lineNumber: lineNumber
Expand Down
Loading