Skip to content

Commit

Permalink
Merge pull request #233 from synonymdev/native-logs
Browse files Browse the repository at this point in the history
feat: write swift and kotlin log events to file
  • Loading branch information
Jasonvdb authored Apr 17, 2024
2 parents 2c89a29 + 5c86171 commit c31e14e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,8 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod

if (res.is_ok) {
txs.pushHexString((res as Result_TransactionNoneZ.Result_TransactionNoneZ_OK).res)
} else {
LdkEventEmitter.send(EventTypes.native_log, "Failed to spend outputs for channel $channelId")
}
}
}
Expand Down Expand Up @@ -1440,5 +1442,9 @@ object LdkEventEmitter {
}

this.reactContext!!.getJSModule(RCTDeviceEventEmitter::class.java).emit(eventType.toString(), body)

if (eventType == EventTypes.native_log) {
LogFile.write("DEBUG (KOTLIN): $body")
}
}
}
4 changes: 4 additions & 0 deletions lib/ios/Ldk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,10 @@ class LdkEventEmitter: RCTEventEmitter {
public func send(withEvent eventType: EventTypes, body: Any) {
//TODO convert all bytes to hex here
sendEvent(withName: eventType.rawValue, body: body)

if eventType == .native_log {
Logfile.log.write("DEBUG (SWIFT): \(body)")
}
}

override func supportedEvents() -> [String] {
Expand Down

0 comments on commit c31e14e

Please sign in to comment.