diff --git a/log.h b/log.h index ac0f9aaa3521daf1cc4eba7ce1b5763208c81eee..8b0071f4578d32d2ee2939cf2a785cfda92a0b39 100644 --- a/log.h +++ b/log.h @@ -20,6 +20,7 @@ determining streaming to the Logfile and/or cout. */ #include <iostream> #include <fstream> #include <string> +#include <iomanip> #include <strstream> #include "newmatap.h" #include "newmatio.h" @@ -134,6 +135,8 @@ namespace Utilities{ bool stream_to_logfile; bool stream_to_cout; + friend Log& operator<<(Log& log, ostream& (*obj) (ostream &)); + template<class t> friend Log& operator<<(Log& log, const t& obj); @@ -214,6 +217,18 @@ namespace Utilities{ return dir + "/" + filename; } + + inline Log& operator<<(Log& log, ostream& (*obj)(ostream &)) + { + if(log.stream_to_logfile) + log.logfileout << obj; + + if(log.stream_to_cout) + cout << obj; + + return log; + } + } #endif