|
Boost : |
From: Darryl Green (darryl.green_at_[hidden])
Date: 2004-10-25 21:07:09
Caleb Epstein <caleb.epstein <at> gmail.com> writes:
>
> On Mon, 25 Oct 2004 14:17:11 +0100, Ben Hutchings
> <ben.hutchings <at> businesswebsoftware.com> wrote:
> > Caleb Epstein wrote:
> > > On Sat, 23 Oct 2004 07:10:48 +0000 (UTC), Darryl Green
> > > <darryl.green <at> unitab.com.au> wrote:
> > >
> > >
> > >> char buf[101];
> > >> va_list args;
> > >> va_start(args, fmt);
> > >> int n = vsnprintf (buf, 101, fmt, args));
> > >> va_end(args);
> > >> if (n < 0) return;
Well, it should probably log a logging failure ;-) at this point
rather than silently doing nothing, but you also snipped the next line:
m.get_stream().write(buf, n > 100 ? 100 : n);
Which does the/a right thing when the snprintf worked but truncated
the output. I am not suggesting this is tested, portable code.
There may be broken snprintf's and I wrote that code in the gmane web
interface - I have no idea if it even compiles. My intent was only to
illustrate that it isn't hard to modify/extend the logging library for
particular user requirements (not mine btw).
Regards
Darryl.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk