Analyze debug condition in template
novice3
sorryno at em.ail
Tue Oct 26 05:22:51 UTC 2021
Hello.
Need advice:
Is it possible analyze "debug" condition in template, obtained
from instantiation place?
Like we using __LINE__ ?
For example, i have template for logging:
```d
void logf(string func = __FUNCTION__, int line = __LINE__,
A...)(string fmt, A args)
{
// here i want analyze, if debug == func
// and writef conditionally
writefln("%s:%d " ~ fmt, func, line, args);
}
```
And i want switch on logging for one function module1.func(),
then i declare in module1
```d
debug = func1; // enable logging for func1
void func1()
{
...
logf("var1=%d", var1);
...
}
```
And i want to check in logf()() template: is debug condition
equal function name, which instantiate logf() template.
Just advise me direction or proper keyword ...
Thanks.
More information about the Digitalmars-d-learn
mailing list