I want to output the function name each time it is called, I can easily copy and paste the function name, however I wondered if there was a shortcut that would do the job for me?
At the moment I am doing:
SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream & in)
{
qDebug("lynxThreeFile::readSlideInfoHeader");
}
but what I want is something generic:
SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream & in)
{
qDebug(this.className() + "::" + this.functionName());
}
Use the __name__ Property to Get the Function Name in Python To access the __name__ property, just put in the function name without the parentheses and use the property accessor . __name__ . It will then return the function name as a string.
Using __name__ method, we can return the function name in the python program. In our example, we have created a function with the name 'basket' and then we have returned basket. __name__ . Everytime this function will be called function name will be printed on the display screen.
"__FUNCTION__
" is supported by both MSVC and GCC and should give you the information you need.
I see from your example that you are using Qt. In which case your best bet is to use Q_FUNC_INFO
found in <QGlobal>
. Here's the description:
Expands to a string that describe the function the macro resides in. How this string looks more specifically is compiler dependent. With GNU GCC it is typically the function signature, while with other compilers it might be the line and column number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With