1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include "logbuffer.ih"
int LogBuffer::overflow(int c)
{
if (!d_active) // ignore the char if we're not active.
return c;
if (c == 0) // newline without timestamp request
d_empty = false;
if (d_insertTimestamp) // timestamps requested
{
if (d_empty) // write one if there's nothing on the line
{
insertTimestamp();
d_empty = false;
}
}
switch (c)
{
case 0: // write newline, without considering d_empty true
c = '\n'; // also see logbuffer/operatorinsert.cc
break;
case '\n': // at '\n', set d_empty to true. This generates
// a timestamp at the next insertion
d_empty = true;
break;
}
return
d_stream->write(reinterpret_cast<char const *>(&c), sizeof(char)) ?
c
:
EOF;
}
|