added logging

This commit is contained in:
Mauro Romito
2023-05-31 19:26:40 +02:00
parent 10ebf63b67
commit f64e386562
7 changed files with 24 additions and 16 deletions

View File

@@ -18,3 +18,4 @@
// https://help.apple.com/xcode/#/dev745c5c974
#include "Common.xcconfig"
#include "Pods/Target Support Files/Pods-RiotPods-BroadcastUploadExtension/Pods-RiotPods-BroadcastUploadExtension.debug.xcconfig"

View File

@@ -18,6 +18,7 @@
// https://help.apple.com/xcode/#/dev745c5c974
#include "Common.xcconfig"
#include "Pods/Target Support Files/Pods-RiotPods-BroadcastUploadExtension/Pods-RiotPods-BroadcastUploadExtension.release.xcconfig"
PROVISIONING_PROFILE = $(BROADCAST_UPLOAD_EXTENSION_PROVISIONING_PROFILE)
PROVISIONING_PROFILE_SPECIFIER = $(BROADCAST_UPLOAD_EXTENSION_PROVISIONING_PROFILE_SPECIFIER)

View File

@@ -7,6 +7,8 @@
import ReplayKit
import MatrixSDK
private enum Constants {
// the App Group ID value that the app and the broadcast extension targets are setup with. It differs for each app.
static let appGroupIdentifier = BuildSettings.applicationGroupIdentifier
@@ -74,7 +76,7 @@ private extension SampleHandler {
func setupConnection() {
clientConnection?.didClose = { [weak self] error in
print("client connection did close \(String(describing: error))")
MXLog.error("client connection did close", context: error)
if let error = error {
self?.finishBroadcastWithError(error)

View File

@@ -9,6 +9,8 @@
import Foundation
import ReplayKit
import MatrixSDK
private enum Constants {
static let bufferMaxLength = 10240
}
@@ -90,7 +92,7 @@ private extension SampleUploader {
byteIndex = 0
}
} else {
print("writeBufferToStream failure")
MXLog.error("writeBufferToStream failure")
}
return true
@@ -98,7 +100,7 @@ private extension SampleUploader {
func prepare(sample buffer: CMSampleBuffer) -> Data? {
guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else {
print("image buffer not available")
MXLog.error("image buffer not available")
return nil
}
@@ -115,7 +117,7 @@ private extension SampleUploader {
CVPixelBufferUnlockBaseAddress(imageBuffer, .readOnly)
guard let messageData = bufferData else {
print("corrupted image buffer")
MXLog.error("corrupted image buffer")
return nil
}

View File

@@ -8,6 +8,8 @@
import Foundation
import MatrixSDK
class SocketConnection: NSObject {
var didOpen: (() -> Void)?
var didClose: ((Error?) -> Void)?
@@ -28,16 +30,16 @@ class SocketConnection: NSObject {
socketHandle = Darwin.socket(AF_UNIX, SOCK_STREAM, 0)
guard socketHandle != -1 else {
print("failure: create socket")
MXLog.error("failure: create socket")
return nil
}
}
func open() -> Bool {
print("open socket connection")
MXLog.info("open socket connection")
guard FileManager.default.fileExists(atPath: filePath) else {
print("failure: socket file missing")
MXLog.error("failure: socket file missing")
return false
}
@@ -80,7 +82,7 @@ extension SocketConnection: StreamDelegate {
func stream(_ aStream: Stream, handle eventCode: Stream.Event) {
switch eventCode {
case .openCompleted:
print("client stream open completed")
MXLog.info("client stream open completed")
if aStream == outputStream {
didOpen?()
}
@@ -89,7 +91,7 @@ extension SocketConnection: StreamDelegate {
var buffer: UInt8 = 0
let numberOfBytesRead = inputStream?.read(&buffer, maxLength: 1)
if numberOfBytesRead == 0 && aStream.streamStatus == .atEnd {
print("server socket closed")
MXLog.info("server socket closed")
close()
notifyDidClose(error: nil)
}
@@ -99,7 +101,7 @@ extension SocketConnection: StreamDelegate {
streamHasSpaceAvailable?()
}
case .errorOccurred:
print("client stream error occured: \(String(describing: aStream.streamError))")
MXLog.error("client stream error occured", context: aStream.streamError)
close()
notifyDidClose(error: aStream.streamError)
@@ -114,7 +116,7 @@ private extension SocketConnection {
func setupAddress() -> Bool {
var addr = sockaddr_un()
guard filePath.count < MemoryLayout.size(ofValue: addr.sun_path) else {
print("failure: fd path is too long")
MXLog.error("failure: fd path is too long")
return false
}
@@ -140,7 +142,7 @@ private extension SocketConnection {
}
guard status == noErr else {
print("failure: \(status)")
MXLog.error("connect socket failure", context: status)
return false
}

View File

@@ -6,9 +6,5 @@
<array>
<string>$(APPLICATION_GROUP_IDENTIFIER)</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>$(KEYCHAIN_ACCESS_GROUP)</string>
</array>
</dict>
</plist>

View File

@@ -127,6 +127,10 @@ abstract_target 'RiotPods' do
import_MatrixKit_pods
end
target "BroadcastUploadExtension" do
import_MatrixSDK
end
end
post_install do |installer|