johnno1962 / SwiftTrace

Trace Swift and Objective-C method invocations
Other
707 stars 52 forks source link

I'm using CocoaDebug #13

Closed 8secz-johndpope closed 5 years ago

8secz-johndpope commented 5 years ago

https://github.com/CocoaDebug/CocoaDebug/tree/master/Example_Swift

it has a line to override print stuff https://github.com/CocoaDebug/CocoaDebug/blob/master/Example_Swift/AppDelegate.swift#L40

how can I reroute swift to this?

I'm thinking we need a delegate to pass back to app - or is there a better way you can think of?

this didn't work

extension SwiftTrace{
    override open func onExit(stack: inout ExitStack) {
        if let invocation = Invocation.current {
            print("\(String(repeating: "  ", count: invocation.stackDepth))\(name) \(String(format: "%.1fms", elapsed ))")
        }
    }
}
johnno1962 commented 5 years ago

Hi, I'm not sure what you are looking to do but if you want to introduce a delegate your best bet is to try subclassing the SwiftTrace.Patch class and change the SwiftTrace.patchFactory to override onEntry or onExit.

8secz-johndpope commented 5 years ago

in flight / on device logging https://github.com/CocoaDebug/CocoaDebug the instructions you've given in the readme should help - will test tomorrow. thx