mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 23:25:20 +00:00
Add comprehensive logging system for debugging
- Create LoggingService that writes to Documents/Logs directory - Log to both console and file with timestamps - Replace debug print statements with bitchatLog() - Add log file location display in AppInfoView - Enable opening log file in Finder on macOS - Track room member operations and view state - Persist logs for debugging room member display issues
This commit is contained in:
@@ -111,6 +111,31 @@ struct AppInfoView: View {
|
||||
.foregroundColor(textColor)
|
||||
}
|
||||
|
||||
// Debug Info
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
SectionHeader("Debug")
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("Log Location:")
|
||||
.font(.system(size: 14, weight: .semibold, design: .monospaced))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Text(LoggingService.shared.getLogFileURL().path)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
.foregroundColor(secondaryTextColor)
|
||||
.textSelection(.enabled)
|
||||
|
||||
#if os(macOS)
|
||||
Button("Open in Finder") {
|
||||
NSWorkspace.shared.selectFile(LoggingService.shared.getLogFileURL().path, inFileViewerRootedAtPath: "")
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Version
|
||||
HStack {
|
||||
Spacer()
|
||||
@@ -208,6 +233,31 @@ struct AppInfoView: View {
|
||||
.foregroundColor(textColor)
|
||||
}
|
||||
|
||||
// Debug Info
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
SectionHeader("Debug")
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("Log Location:")
|
||||
.font(.system(size: 14, weight: .semibold, design: .monospaced))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Text(LoggingService.shared.getLogFileURL().path)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
.foregroundColor(secondaryTextColor)
|
||||
.textSelection(.enabled)
|
||||
|
||||
#if os(macOS)
|
||||
Button("Open in Finder") {
|
||||
NSWorkspace.shared.selectFile(LoggingService.shared.getLogFileURL().path, inFileViewerRootedAtPath: "")
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 12, design: .monospaced))
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Version
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
@@ -601,9 +601,9 @@ struct ContentView: View {
|
||||
if let currentRoom = viewModel.currentRoom,
|
||||
let roomMemberIDs = viewModel.roomMembers[currentRoom] {
|
||||
// Show only peers who have sent messages to this room (including self)
|
||||
print("[DEBUG-VIEW] Room \(currentRoom) has members: \(roomMemberIDs)")
|
||||
print("[DEBUG-VIEW] Connected peers: \(viewModel.connectedPeers)")
|
||||
print("[DEBUG-VIEW] My peer ID: \(myPeerID)")
|
||||
bitchatLog("Room \(currentRoom) has members: \(roomMemberIDs)", category: "view")
|
||||
bitchatLog("Connected peers: \(viewModel.connectedPeers)", category: "view")
|
||||
bitchatLog("My peer ID: \(myPeerID)", category: "view")
|
||||
|
||||
// Start with room members who are also connected
|
||||
var memberPeers = viewModel.connectedPeers.filter { roomMemberIDs.contains($0) }
|
||||
@@ -613,7 +613,7 @@ struct ContentView: View {
|
||||
memberPeers.append(myPeerID)
|
||||
}
|
||||
|
||||
print("[DEBUG-VIEW] Peers to show in room: \(memberPeers)")
|
||||
bitchatLog("Peers to show in room: \(memberPeers)", category: "view")
|
||||
return memberPeers
|
||||
} else {
|
||||
// Show all connected peers in main chat
|
||||
|
||||
Reference in New Issue
Block a user