/*---------------------------- logstream.h ---------------------------*/
+#include <base/exceptions.h>
+
#include <string>
#include <stack>
#include <iostream>
* previously attached to this object.
*/
void detach();
-
+ /**
+ * Gives the default stream (#std_out#).
+ */
+ ostream& get_console();
+
+ /**
+ * Gives the file stream.
+ */
+ ostream& get_file_stream();
/**
* Push another prefix on the
* Declare this function as a friend.
*/
friend void endl (LogStream &);
+
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNoFileStreamGiven);
+
private:
/**
* Print head of line. This prints
/* ----------------------------- Inline functions and templates ---------------- */
-inline
-void
-LogStream::push (const string& text)
-{
- // strange enough: if make this
- // function non-inline with
- // gcc2.8, we get very strange
- // compiler errors...
- string pre=prefixes.top();
- pre += text;
- pre += string(":");
- prefixes.push(pre);
-}
-
-inline
-void
-LogStream::log_execution_time(bool flag)
-{
- print_utime = flag;
-}
-
// sorry for the weird following declaration spanning 5 lines, but
// doc++ gets confused if we be more compact :-(
void LogStream::detach ()
{
file = 0;
+};
+
+
+
+ostream&
+LogStream::get_console()
+{
+ return *std_out;
+}
+
+
+
+ostream&
+LogStream::get_file_stream()
+{
+ Assert(file, ExcNoFileStreamGiven());
+ return *file;
}
void
-LogStream::pop ()
+LogStream::push (const string& text)
+{
+ // strange enough: if make this
+ // function non-inline with
+ // gcc2.8, we get very strange
+ // compiler errors...
+ string pre=prefixes.top();
+ pre += text;
+ pre += string(":");
+ prefixes.push(pre);
+}
+
+
+void LogStream::pop ()
{
prefixes.pop();
}
LogStream::depth_console(unsigned n)
{
std_depth = n;
-}
+};
LogStream::depth_file(unsigned n)
{
file_depth = n;
+};
+
+
+
+void
+LogStream::log_execution_time(bool flag)
+{
+ print_utime = flag;
}
+
void
LogStream::print_line_head()
{
}
+
LogStream&
LogStream::operator << (void (f)(LogStream &))
{
f(*this);
return *this;
}
+
+
+