www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Bug in logger

reply "Prudence" <Pursuit Happyness.All> writes:
\..\..\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.
Sep 03 2015
next sibling parent reply "Mike Parker" <aldacron gmail.com> writes:
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?
Sep 03 2015
parent reply "Prudence" <Pursuit Happyness.All> writes:
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.
Sep 04 2015
parent "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
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.
Sep 04 2015
prev sibling parent reply "Robert burner Schadek" <rburners gmail.com> writes:
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");
}
Sep 04 2015
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
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
Sep 04 2015