On Wednesday, 12 July 2023 at 05:27:27 UTC, mw wrote:
But what's wrong with my code? the strange compiler error?
Might be a bug/issue in the logger module.
`sharedLog` uses the `shared` attribute,
but the base class for everything ("abstract class Logger")
does not use the `shared` attribute anywhere.
-
https://github.com/dlang/phobos/blob/master/std/logger/core.d#L516C22-L516C22
It works when you cast away the `shared` attribute from
`sharedLog`,
so I think that's the problem.
```d
import std.stdio;
import std.logger;
void main() {
stdThreadLocalLog = new FileLogger(stderr);
stdThreadLocalLog.trace("local msg");
//-----------------------------------------------
sharedLog = cast(shared)new FileLogger(stderr);
//sharedLog.trace("shared msg");
// ERROR
(cast()sharedLog).trace("shared msg");
// WORKS, cast away 'shared'
//sharedLog.memLogFunctions!(LogLevel.trace).logImpl("shared
msg"); // ERROR
(cast()sharedLog).memLogFunctions!(LogLevel.trace).logImpl("shared msg"); // WORKS, cast away 'shared'
}
```