// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
* standard output stream to <tt>std::cerr</tt>.
*/
LogStream ();
+
+ /**
+ * Destructor.
+ */
+ ~LogStream();
/**
* Enable output to a second
/**
* Reroutes cerr to LogStream.
+ * Works as a switch, turning
+ * logging of <tt>cerr</tt> on
+ * and of alternatingly with
+ * every call.
*/
void log_cerr ();
*/
template <typename T>
void print (const T &t);
+ /**
+ * Original buffer of
+ * <tt>cerr</tt> in order to
+ * leave this class properly.
+ */
+ std::ostream::__streambuf_type* old_cerr;
};
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
std_out(&std::cerr), file(0), was_endl(true),
std_depth(10000), file_depth(10000),
print_utime(false), diff_utime(false),
- last_time (0.)
+ last_time (0.), old_cerr(0)
{
prefixes.push("DEAL:");
std_out->setf(std::ios::showpoint | std::ios::left);
}
+LogStream::~LogStream()
+{
+ if (old_cerr)
+ std::cerr.rdbuf(old_cerr);
+}
+
+
void
LogStream::attach(std::ostream& o)
{
void LogStream::log_cerr ()
{
- std::cerr.rdbuf(file->rdbuf());
+ if (old_cerr == 0)
+ {
+ old_cerr = std::cerr.rdbuf(file->rdbuf());
+ } else {
+ std::cerr.rdbuf(old_cerr);
+ old_cerr = 0;
+ }
}