Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameter 'subLevels' doesn't work #42

Closed
neebel opened this issue Apr 24, 2022 · 1 comment
Closed

parameter 'subLevels' doesn't work #42

neebel opened this issue Apr 24, 2022 · 1 comment

Comments

@neebel
Copy link

neebel commented Apr 24, 2022

SwiftTrace.traceMainBundle(subLevels: 3)

when i set parameter 'subLevels' to 3, all methods are traced, not top 3 level methods.

public func f1() {
f2()
}

public func f2() {
f3()
}

public func f3() {
f4()
}

public func f4() {

}

I expect f1、f2、f3 are traced and f4 are not traced, what can I to do?

@johnno1962
Copy link
Owner

johnno1962 commented Apr 24, 2022

Hi, I'm afraid subLevels isn't entirely thought out or implemented and it's a long time since I've looked at it. IIRC, the idea was if you are filtering by instance or class you can bring in the trace of N sub levels of calls below a qualifying call. In this case, as there is no filtering the counter is continually reset. Is getting this working important to you? How would you have it work?

                if (swizzle.trace.instanceFilter == nil ||
                    swizzle.trace.instanceFilter == swiftSelf) &&
                    (swizzle.trace.classFilter == nil ||
                     swizzle.trace.classFilter === swizzle.getClass()) {
                    threadLocal.levelsTracing = swizzle.trace.subLevels
                    return true
                }

The idea was you could use filters to select out methods you were interested in and also see the methods they called e.g.

class C: NSObject {
    var t = "t"
    lazy var c = C()
    func f() {}
    public func f1() {
        c.f2()
    }

    public func f2() {
        c.f3()
    }

    public func f3() {
        c.f4()
    }

    public func f4() {

    }

}
...
        let c = C()
        c.swiftTraceInstance(withSubLevels: 3)
        c.f1()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants