Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 03, 2015 Bug in logger | ||||
---|---|---|---|---|
| ||||
\..\..\src\phobos\std\experimental\logger\core.d(1784): Error: static variable stdLoggerThreadLogger cannot be read at compile time I'm trying to use the logger in a static this. It should work or, if it can't, quietly fail(not log anything)... and not break the program. |
September 04, 2015 Re: Bug in logger | ||||
---|---|---|---|---|
| ||||
Posted in reply to Prudence | On Thursday, 3 September 2015 at 23:09:18 UTC, Prudence wrote:
> \..\..\src\phobos\std\experimental\logger\core.d(1784): Error: static variable stdLoggerThreadLogger cannot be read at compile time
>
> I'm trying to use the logger in a static this. It should work or, if it can't, quietly fail(not log anything)... and not break the program.
The error tells you you're trying to use something in a compile-time context that can't be used at compile time. You *should* get errors in that situation. Can you share the offending code?
|
September 04, 2015 Re: Bug in logger | ||||
---|---|---|---|---|
| ||||
Posted in reply to Prudence | the sharedLog Logger (aka default logger) will only work after its static this has run. you could create a new Logger and use this one. static this() { auto tmpLog = new FileLogger("logfile.log"); tmpLog.log("Hello World"); } |
September 04, 2015 Re: Bug in logger | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert burner Schadek | On 9/4/15 4:30 AM, Robert burner Schadek wrote:
> the sharedLog Logger (aka default logger) will only work after its
> static this has run.
D shouldn't have a problem with this. It uses import dependencies to make sure the static ctors are run in dependency order.
-Steve
|
September 04, 2015 Re: Bug in logger | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Friday, 4 September 2015 at 01:00:24 UTC, Mike Parker wrote:
> On Thursday, 3 September 2015 at 23:09:18 UTC, Prudence wrote:
>> \..\..\src\phobos\std\experimental\logger\core.d(1784): Error: static variable stdLoggerThreadLogger cannot be read at compile time
>>
>> I'm trying to use the logger in a static this. It should work or, if it can't, quietly fail(not log anything)... and not break the program.
>
> The error tells you you're trying to use something in a compile-time context that can't be used at compile time. You *should* get errors in that situation. Can you share the offending code?
Wait, that makes no sense... The error is in phobos... not my code. THAT specifically means that it is a phobos problem, irrespective of what I'm doing.
|
September 04, 2015 Re: Bug in logger | ||||
---|---|---|---|---|
| ||||
Posted in reply to Prudence | On Friday, 4 September 2015 at 17:46:11 UTC, Prudence wrote: > On Friday, 4 September 2015 at 01:00:24 UTC, Mike Parker wrote: >> On Thursday, 3 September 2015 at 23:09:18 UTC, Prudence wrote: >>> \..\..\src\phobos\std\experimental\logger\core.d(1784): Error: static variable stdLoggerThreadLogger cannot be read at compile time >>> >>> I'm trying to use the logger in a static this. It should work or, if it can't, quietly fail(not log anything)... and not break the program. >> >> The error tells you you're trying to use something in a compile-time context that can't be used at compile time. You *should* get errors in that situation. Can you share the offending code? > > Wait, that makes no sense... The error is in phobos... not my code. THAT specifically means that it is a phobos problem, irrespective of what I'm doing. Is the above the _entire_ error message? For a simple test program, I get the following: int sayHello() { import std.stdio; writeln("Hello!"); return 42; } enum value = sayHello(); // line 7 /home/marc/d/phobos/std/stdio.d(3012): Error: static variable stdout cannot be read at compile time /home/marc/d/phobos/std/stdio.d(3076): called from here: trustedStdout() xx.d(3): called from here: writeln("Hello!") xx.d(7): called from here: sayHello() Notice the lines saying "called from here". They will point you to the place where the compile-time evaluation is started. |
Copyright © 1999-2021 by the D Language Foundation