Bug 14940 – Can't call logger with more complex objects
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-08-20T13:24:00Z
Last change time
2015-10-04T18:20:31Z
Assigned to
nobody
Creator
dmdtracker
Comments
Comment #0 by dmdtracker — 2015-08-20T13:24:40Z
I can't call the logger with any more complex objects. It used to work in the older version in the dedicated repository before it was merged into phobos.
Example code:
import std.experimental.logger.filelogger;
import std.typecons: Nullable;
import std.stdio;
void main ( )
{
Nullable!int a = 1;
auto l = new FileLogger(stdout);
l.infof("log: %s", l);
}
Error:
phobos/std/experimental/logger/core.d(1121): Error: safe function 'std.experimental.logger.core.Logger.memLogFunctions!cast(LogLevel)cast(ubyte)64u.logImplf!(11, "main.d", "main.main", "void main.main()", "main", FileLogger).logImplf' cannot call system function 'std.format.formattedWrite!(MsgRange, char, FileLogger).formattedWrite'
main.d(11): Error: template instance std.experimental.logger.core.Logger.memLogFunctions!cast(LogLevel)cast(ubyte)64u.logImplf!(11, "main.d", "main.main", "void main.main()", "main", FileLogger) error instantiating
Comment #1 by dmdtracker — 2015-08-20T13:43:52Z
Other problems are for example when trying to print the json object that vibe.d gives the handler. Results in the same error.
Comment #2 by rburners — 2015-08-25T22:08:05Z
I will work on this
Comment #3 by rburners — 2015-08-25T22:25:24Z
the code tries to log the Logger.
If I change it to log the Nullable is still does not work, because the toString of Nullable takes a @system delegate OutputRange.