API: string formatting / memory management

Robert burner Schadek via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 14:14:36 PDT 2014


On Friday, 11 July 2014 at 15:20:51 UTC, Johannes Pfau wrote:
>
> writeLogHeader would receive all data as usual, except for the 
> message
> string. Then after calling writeLogHeader, the (formatted) 
> message
> string will be passed in any number of calls to put.
>
> I used put here to make this output-range compatible. This way 
> it plugs
> directly into formattedWrite.
>
>
> An logger can still receive the complete string by appending 
> the chunks
> received in put but we might need some 'finish' function to 
> signal the
> end of the message. I guess not all loggers can fit into this
> interface, so we should try to make this optional. But simple 
> loggers
> (file, console) which write the header first and the message 
> last could
> work without any dynamic memory allocation. (formattedWrite 
> probably
> uses an fixed-size buffer on the stack, but that's fine)

The api for none printf like logging has changed into something
like
write. So put properly needs to become a template. Any I'm not
sure if
there is a nice way around the template/inheritance problematic.
Other
than options one and two.


More information about the Digitalmars-d mailing list