Skip to content

Commit d434b05

Browse files
committed
improve logging with file and line info
1 parent f181da1 commit d434b05

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

ios/RiveReactNativeViewManager.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,83 +10,83 @@ class RiveReactNativeViewManager: RCTViewManager {
1010
return view
1111
}
1212

13-
private func withRiveReactNativeView(_ node: NSNumber, _ handler: @escaping (RiveReactNativeView) -> Void) {
13+
private func withRiveReactNativeView(_ node: NSNumber, _ file: String=#file, _ line: UInt=#line, _ handler: @escaping (RiveReactNativeView) -> Void) {
1414
DispatchQueue.main.async {
1515
guard let bridge = self.bridge else {
16-
RCTLogError("Bridge is nil when trying to access RiveReactNativeView")
16+
RCTSwiftLog.error("Bridge is nil when trying to access RiveReactNativeView", file: file, line: line)
1717
return
1818
}
1919

20-
guard let view = bridge.uiManager.view(forReactTag: node) else {
21-
RCTLogError("Could not find view with tag: \(node)")
20+
guard let view = bridge.uiMan ager.view(forReactTag: node) else {
21+
RCTSwiftLog.error("Could not find view with tag: \(node)", file: file, line:line)
2222
return
2323
}
2424

2525
guard let riveView = view as? RiveReactNativeView else {
26-
RCTLogError("View with tag \(node) is not a RiveReactNativeView, got \(String(describing: type(of: view))) instead")
26+
RCTSwiftLog.error("View with tag \(node) is not a RiveReactNativeView, got \(String(describing: type(of: view))) instead", file: file, line: line)
2727
return
2828
}
2929

3030
handler(riveView)
3131
}
3232
}
33-
33+
3434
@objc func play(_ node: NSNumber, animationName: String, loop: String, direction: String, isStateMachine: Bool) {
3535
withRiveReactNativeView(node) {
3636
$0.play(animationName: animationName, rnLoopMode: RNLoopMode.mapToRNLoopMode(value: loop), rnDirection: RNDirection.mapToRNDirection(value: direction), isStateMachine: isStateMachine)
3737
}
3838
}
39-
39+
4040
@objc func pause(_ node: NSNumber) {
4141
withRiveReactNativeView(node) { $0.pause() }
4242
}
43-
43+
4444
@objc func stop(_ node: NSNumber) {
4545
withRiveReactNativeView(node) { $0.stop() }
4646
}
47-
47+
4848
@objc func reset(_ node: NSNumber) {
4949
withRiveReactNativeView(node) { $0.reset() }
5050
}
51-
51+
5252
@objc func fireState(_ node: NSNumber, stateMachineName: String, inputName: String) {
5353
withRiveReactNativeView(node) { $0.fireState(stateMachineName: stateMachineName, inputName: inputName) }
5454
}
55-
55+
5656
@objc func setBooleanState(_ node: NSNumber, stateMachineName: String, inputName: String, value: Bool) {
5757
withRiveReactNativeView(node) { $0.setBooleanState(stateMachineName: stateMachineName, inputName: inputName, value: value) }
5858
}
59-
59+
6060
@objc func setNumberState(_ node: NSNumber, stateMachineName: String, inputName: String, value: NSNumber) {
6161
withRiveReactNativeView(node) { $0.setNumberState(stateMachineName: stateMachineName, inputName: inputName, value: Float(truncating: value)) }
6262
}
63-
63+
6464
@objc func fireStateAtPath(_ node: NSNumber, inputName: String, path: String) {
6565
withRiveReactNativeView(node) { $0.fireStateAtPath(inputName: inputName, path: path) }
6666
}
67-
67+
6868
@objc func setBooleanStateAtPath(_ node: NSNumber, inputName: String, value: Bool, path: String) {
6969
withRiveReactNativeView(node) { $0.setBooleanStateAtPath(inputName: inputName, value: value, path: path) }
7070
}
71-
71+
7272
@objc func setNumberStateAtPath(_ node: NSNumber, inputName: String, value: NSNumber, path: String) {
7373
withRiveReactNativeView(node) { $0.setNumberStateAtPath(inputName: inputName, value: Float(truncating: value), path: path) }
7474
}
75-
75+
7676
@objc func touchBegan(_ node: NSNumber, x: NSNumber, y: NSNumber) {
7777
withRiveReactNativeView(node) {
7878
let touch = CGPoint(x: x.doubleValue, y: y.doubleValue)
7979
$0.touchBegan(touch)
8080
}
8181
}
82-
82+
8383
@objc func touchEnded(_ node: NSNumber, x: NSNumber, y: NSNumber) {
8484
withRiveReactNativeView(node) {
8585
let touch = CGPoint(x: x.doubleValue, y: y.doubleValue)
8686
$0.touchEnded(touch)
8787
}
8888
}
89-
89+
9090
@objc func setTextRunValue(_ node: NSNumber, textRunName: String, textRunValue: String) {
9191
withRiveReactNativeView(node) {
9292
do {
@@ -96,7 +96,7 @@ class RiveReactNativeViewManager: RCTViewManager {
9696
}
9797
}
9898
}
99-
99+
100100
@objc func setTextRunValueAtPath(_ node: NSNumber, textRunName: String, textRunValue: String, path: String) {
101101
withRiveReactNativeView(node) {
102102
do {
@@ -106,35 +106,35 @@ class RiveReactNativeViewManager: RCTViewManager {
106106
}
107107
}
108108
}
109-
109+
110110
@objc func setBooleanPropertyValue(_ node: NSNumber, path: String, value: Bool) {
111111
withRiveReactNativeView(node) { $0.setBooleanPropertyValue(path: path, value: value) }
112112
}
113-
113+
114114
@objc func setStringPropertyValue(_ node: NSNumber, path: String, value: String) {
115115
withRiveReactNativeView(node) { $0.setStringPropertyValue(path: path, value: value) }
116116
}
117-
117+
118118
@objc func setNumberPropertyValue(_ node: NSNumber, path: String, value: NSNumber) {
119119
withRiveReactNativeView(node) { $0.setNumberPropertyValue(path: path, value: Float(truncating: value)) }
120120
}
121-
121+
122122
@objc func setColorPropertyValue(_ node: NSNumber, path: String, r: NSNumber, g: NSNumber, b: NSNumber, a: NSNumber) {
123123
withRiveReactNativeView(node) { $0.setColorPropertyValue(path: path, r: r.intValue, g: g.intValue, b: b.intValue, a: a.intValue) }
124124
}
125-
125+
126126
@objc func setEnumPropertyValue(_ node: NSNumber, path: String, value: String) {
127127
withRiveReactNativeView(node) { $0.setEnumPropertyValue(path: path, value: value) }
128128
}
129-
129+
130130
@objc func fireTriggerProperty(_ node: NSNumber, path: String) {
131131
withRiveReactNativeView(node) { $0.fireTriggerProperty(path: path) }
132132
}
133-
133+
134134
@objc func registerPropertyListener(_ node: NSNumber, path: String, propertyType: String) {
135135
withRiveReactNativeView(node) { $0.registerPropertyListener(path: path, propertyType: propertyType) }
136136
}
137-
137+
138138
@objc static override func requiresMainQueueSetup() -> Bool {
139139
return false
140140
}

0 commit comments

Comments
 (0)