GC free Writer

David d at dav1d.de
Fri Feb 8 07:57:39 PST 2013


I am currently implementing a logging module, I want to make logging to
stderr/stdout/"any file" possible, also during runtime-shutdown (logging
from dtors)

Atm it lookes like this:

----
void log(LogLevel level, Args...)(Args args) {
    string message = format(args);

    ... pass string to writer
}
---

But format allocates! That makes it throw an InvalidMemoryOperationError
when calling the logging function from a dtor. So I need a GC-free
writer for std.format.formattedWrite, similiar to std.stdio's
LockingTextWriter but with a buffer instead of a file
(std.array.Appender GC free something like that). I couldn't come up
with a working solution, I hope you have ideas.



More information about the Digitalmars-d-learn mailing list