mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Improvements to logging (#457)
* Use `.info` logging in most places. * Remove old objc logging support. * Fix table view controller. * Make sure timeline item content isn't logged. * Add tests.
This commit is contained in:
@@ -53,7 +53,8 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
||||
|
||||
switch await roomProxy.addTimelineListener(listener: roomTimelineListener) {
|
||||
case .failure:
|
||||
MXLog.error("Failed adding timeline listener on room with identifier: \(await roomProxy.id)")
|
||||
let roomID = await roomProxy.id
|
||||
MXLog.error("Failed adding timeline listener on room with identifier: \(roomID)")
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
func sendMessage(_ message: String) async {
|
||||
MXLog.info("Send message in \(roomId)")
|
||||
switch await timelineProvider.sendMessage(message) {
|
||||
default:
|
||||
break
|
||||
@@ -153,6 +154,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
func sendReply(_ message: String, to itemId: String) async {
|
||||
MXLog.info("Send reply in \(roomId)")
|
||||
switch await timelineProvider.sendMessage(message, inReplyToItemId: itemId) {
|
||||
default:
|
||||
break
|
||||
@@ -160,6 +162,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
func sendReaction(_ reaction: String, for itemId: String) async {
|
||||
MXLog.info("Send reaction in \(roomId)")
|
||||
switch await timelineProvider.sendReaction(reaction, for: itemId) {
|
||||
default:
|
||||
break
|
||||
@@ -167,6 +170,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
func editMessage(_ newMessage: String, of itemId: String) async {
|
||||
MXLog.info("Edit message in \(roomId)")
|
||||
switch await timelineProvider.editMessage(newMessage, originalItemId: itemId) {
|
||||
default:
|
||||
break
|
||||
@@ -174,6 +178,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
func redact(_ eventID: String) async {
|
||||
MXLog.info("Send redaction in \(roomId)")
|
||||
switch await timelineProvider.redact(eventID) {
|
||||
default:
|
||||
break
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
// MARK: Redact message content from logs
|
||||
|
||||
extension EmoteMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
|
||||
extension FileMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
|
||||
extension ImageMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
|
||||
extension NoticeMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
|
||||
extension TextMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
|
||||
extension VideoMessageContent: CustomStringConvertible {
|
||||
public var description: String {
|
||||
String(describing: Self.self)
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -19,7 +19,8 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
/// A protocol that contains the base `m.room.message` event content properties.
|
||||
protocol MessageContentProtocol: RoomMessageEventContentProtocol {
|
||||
/// The `CustomStringConvertible` conformance is to redact specific properties from the logs.
|
||||
protocol MessageContentProtocol: RoomMessageEventContentProtocol, CustomStringConvertible {
|
||||
var body: String { get }
|
||||
}
|
||||
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct EmoteRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -32,3 +31,11 @@ struct EmoteRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension EmoteRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct FileRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -35,3 +34,11 @@ struct FileRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hasha
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension FileRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct ImageRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -40,3 +39,11 @@ struct ImageRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension ImageRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct NoticeRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -32,3 +31,11 @@ struct NoticeRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Has
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension NoticeRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct TextRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -32,3 +31,11 @@ struct TextRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hasha
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension TextRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -14,7 +14,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct VideoRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hashable {
|
||||
@@ -42,3 +41,11 @@ struct VideoRoomTimelineItem: EventBasedTimelineItemProtocol, Identifiable, Hash
|
||||
|
||||
var properties = RoomTimelineItemProperties()
|
||||
}
|
||||
|
||||
// MARK: - Redact content from logs
|
||||
|
||||
extension VideoRoomTimelineItem: CustomStringConvertible {
|
||||
var description: String {
|
||||
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user