Logging Function Parameters

Seb seb at wilzba.ch
Sun Mar 18 23:23:27 UTC 2018


On Saturday, 17 March 2018 at 10:34:41 UTC, dom wrote:
> Hi,
>
> I am looking for a method to log the current function name + 
> parameters.
> Getting the name of the current function is simply possible 
> with __PRETTY_FUNCTION__
> Is there some possibility to generically access the parameters 
> of a function such that they can be iterated and printed out?
>
> currently i have something like this:
> log.info(__PRETTY_FUNCTION__,  " ", parameter1, " ", 
> parameter2);
>
> i would like to get to something like that:
> log.info(__PRETTY_FUNCTION__,  " ", parameters.join(", "));

You can't get the parameters names at the moment, but there's a 
PR for it:

https://github.com/dlang/dmd/pull/7821


More information about the Digitalmars-d-learn mailing list