On Wednesday, 27 October 2021 at 08:14:29 UTC, Kagamin wrote:
...
Then the logger can inspect symbols in the template argument
and compare their names to the function name.
Aha, thank you, i will try!
You can do something like
```d
enum LogSettings
{
func1,func2,func3
}
alias logger!LogSettings logf;
void func1()
{
logf(...);
}
```
Then the logger can inspect symbols in the template argument and
compare their names to the function name.
On Tuesday, 26 October 2021 at 15:53:54 UTC, Steven Schveighoffer
wrote:
mixin("debug(" ~ func ~ ") doRealThing();");
Thank you, Steven.
Unfortunately, all variants with global "-debug" in command line
is unhandy.
It leads to ugly, very big command line :(
Note that setting debug versions d
On 10/26/21 11:39 AM, novice2 wrote:
On Tuesday, 26 October 2021 at 09:44:42 UTC, Kagamin wrote:
`debug(func1)writefln(...)`
But specify a global debug version for the compiler:
`dmd -debug=func1 app.d`
i want to eliminate "debug(func1)"
i want to be able on/off debugging for one function or a
On Tuesday, 26 October 2021 at 09:44:42 UTC, Kagamin wrote:
`debug(func1)writefln(...)`
But specify a global debug version for the compiler:
`dmd -debug=func1 app.d`
i want to eliminate "debug(func1)"
i want to be able on/off debugging for one function or another,
and logf() template should "un
Thanks Kagamin!
One more way, i think,
mark function with UDA,
and then analize UDA in template.
But i have problem to implement this:
i have function name __FUNCTION__ in template as sting,
but __traits(getAttributes, __FUNCTION__) want symbol,
not string as second parameter :(
`debug(func1)writefln(...)`
But specify a global debug version for the compiler:
`dmd -debug=func1 app.d`
i want to eliminate "debug(func1)" and "debug(func2)" from code:
```d
debug = func1;// enable logging for func1
//debug = func2; // disable logging for func2
void func1()
{
...
debug(func1) logf("var1=%d", var1);
...
}
void func2()
{
...
debug(func2) logf("var1=%d", var
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)
{
// h