Bug in logger

2015-09-03 Thread Prudence via Digitalmars-d
\..\..\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.






Re: Bug in logger

2015-09-03 Thread Mike Parker via Digitalmars-d

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?


Re: Bug in logger

2015-09-04 Thread Robert burner Schadek via Digitalmars-d
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");
}


Re: Bug in logger

2015-09-04 Thread Steven Schveighoffer via Digitalmars-d

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


Re: Bug in logger

2015-09-04 Thread Prudence via Digitalmars-d

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.




Re: Bug in logger

2015-09-04 Thread via Digitalmars-d

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.