[Asterisk-code-review] logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__ (asterisk[master])
Jaco Kroon
asteriskteam at digium.com
Wed Nov 10 07:40:12 CST 2021
Attention is currently required from: Joshua Colp.
Jaco Kroon has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16661 )
Change subject: logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
> What's the long names that are being truncated? What does the difference look like for this?
For C there is no difference as far as I can tell.
Consider this example:
#include <stdio.h>
int function_name(int i1, int i2, int i3)
{
printf("__FUNCTION__ = %s\n", __FUNCTION__);
printf("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
return i1+i2+i3;
}
int main()
{
return function_name(0, 1, -1);
}
When compiled as "C", this outputs:
__FUNCTION__ = function_name
__PRETTY_FUNCTION__ = function_name
When compiled as "C++", this outputs:
__FUNCTION__ = function_name
__PRETTY_FUNCTION__ = int function_name(int, int, int)
This gets even more interesting when using classes:
#include <stdio.h>
class Function {
public:
static int name(int i1, int i2, int i3)
{
printf("__FUNCTION__ = %s\n", __FUNCTION__);
printf("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
return i1+i2+i3;
}
};
int main()
{
return Function::name(0, 1, -1);
}
__FUNCTION__ = name
__PRETTY_FUNCTION__ = static int Function::name(int, int, int)
So for in-tree functions this will make very little (if any difference), however, for external modules it'll shorten the length of the names prefixed to log entries tremendously.
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16661
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I54101a0bb5f8cb9ef63ec12c5e0d4c8edafff9ed
Gerrit-Change-Number: 16661
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Friendly Automation
Gerrit-CC: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Comment-Date: Wed, 10 Nov 2021 13:40:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211110/f265500b/attachment-0001.html>
More information about the asterisk-code-review
mailing list