float_threshold(0.),
offset(0),
old_cerr(0),
- at_newline(true)
+ at_newline(true),
+ stream_flags(std::ios::showpoint | std::ios::left),
+ stream_width(std::cout.width()),
+ stream_precision(std::cout.precision())
{
get_prefixes().push("DEAL:");
LogStream &
LogStream::operator<< (std::ostream& (*p) (std::ostream &))
{
+
std::ostringstream &stream = get_stream();
+ // save the state of out stream
+ std::ios::fmtflags old_flags = stream.flags(stream_flags);
+ unsigned int old_precision = stream.precision (stream_precision);
+ unsigned int old_width = stream.width (stream_width);
// Print to the internal stringstream:
stream << p;
stream.str("");
}
+ // reset output format
+ stream.flags (old_flags);
+ stream.precision(old_precision);
+ stream.width(old_width);
+
return *this;
}
}
+std::ios::fmtflags
+LogStream::flags(const std::ios::fmtflags f)
+{
+ std::ios::fmtflags tmp = stream_flags;
+ stream_flags = f;
+ return tmp;
+}
+
+
+std::streamsize
+LogStream::precision (const std::streamsize prec)
+{
+ std::streamsize tmp = stream_precision;
+ stream_precision = prec;
+ return tmp;
+}
+
+
+std::streamsize
+LogStream::width (const std::streamsize wide)
+{
+ std::streamsize tmp = stream_width;
+ stream_width = wide;
+ return tmp;
+}
+
+
unsigned int
LogStream::depth_console (const unsigned int n)
{