Indent qdebug output



  • Hi,
    this is an awkward question: I've got a set of methods that calls each other and I'm using a set of qdebug outputs to follow the method call

    @void MyClass:myMethod(){
    qDebug() << "[BEGIN] myMethod";
    ....
    myOtherClassInstance->myMethod2();
    qDebug() << "[END] myMethod";
    }@

    This works great, but with a lot of methods on the stack it becomes a trouble to follow the stacktrace. Is there a simple and quick way to implement the method calls and the qdebug output? Otherwise, is there any other class that can help me obtaining such result?
    Now my output looks like:

    @
    [BEGIN] myMethod
    [BEGIN] myMethod2
    [END] myMethod2
    [END] myMethod
    @

    while I'd like something like:

    @
    [BEGIN] myMethod
    [BEGIN] myMethod2
    [END] myMethod2
    [END] myMethod
    @

    I guess this is not easily possible in C++ or without using AOP, but maybe Qt provides something like this....
    The only solution that comes into my mind is to provide a wrapper around the qDebug that will track and increment the indentation each time I enter a method and will decrease every time I exit.



  • The wrapper solution would have been my suggestion too. It doesn't sound too awkward.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.