16 #ifndef dealii__logstream_h 17 #define dealii__logstream_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/base/exceptions.h> 21 #include <deal.II/base/smartpointer.h> 22 #include <deal.II/base/std_cxx11/shared_ptr.h> 23 #include <deal.II/base/thread_local_storage.h> 31 #ifdef DEAL_II_HAVE_SYS_TIMES_H 32 # include <sys/times.h> 36 int tms_utime, tms_stime, tms_cutime, tms_cstime;
41 DEAL_II_NAMESPACE_OPEN
140 Prefix(
const std::string &text);
146 Prefix(
const std::string &text,
178 void attach (std::ostream &o,
179 const bool print_job_id =
true);
199 void test_mode (
const bool on =
true,
200 const double double_threshold = 1.e-10,
201 const float float_threshold = 1.e-7f,
202 const double offset = 1.e-7);
208 std::ostream &get_console ();
214 std::ostream &get_file_stream ();
220 bool has_file ()
const;
233 const std::string &get_prefix ()
const;
243 void push (
const std::string &text);
262 unsigned int depth_console (
const unsigned int n);
272 unsigned int depth_file (
const unsigned int n);
281 bool log_execution_time (
const bool flag);
296 bool log_time_differences (
const bool flag);
308 bool log_thread_id (
const bool flag);
329 void threshold_double(
const double t);
335 void threshold_float(
const float t);
343 std::streamsize precision (
const std::streamsize prec);
351 std::streamsize width (
const std::streamsize wide);
359 std::ios::fmtflags flags(
const std::ios::fmtflags f);
402 std::size_t memory_consumption ()
const;
414 std::stack<std::string> &get_prefixes()
const;
509 struct tms reference_tms;
527 void print_line_head ();
533 std::ostringstream &get_stream();
555 template <
typename T>
577 if (outstreams.get().get() == 0)
579 outstreams.get().reset (
new std::ostringstream);
580 outstreams.get()->setf(std::ios::showpoint | std::ios::left);
584 return *outstreams.get();
594 std::ostringstream &stream = get_stream();
601 else if (std::fabs(t) < double_threshold)
604 stream << t*(1.+offset);
615 std::ostringstream &stream = get_stream();
621 if (! (t<=0) && !(t>=0))
623 else if (std::fabs(t) < float_threshold)
626 stream << t*(1.+offset);
665 DEAL_II_NAMESPACE_CLOSE
Threads::ThreadLocalStorage< std_cxx11::shared_ptr< std::ostringstream > > outstreams
A class that provides a separate storage location on each thread that accesses the object...
Threads::ThreadLocalStorage< std::stack< std::string > > prefixes
bool is_finite(const double x)
std::streambuf * old_cerr
LogStream & operator<<(const double t)
Prefix(const std::string &text)
double reference_time_val
std::ostringstream & get_stream()
StreamType & operator<<(StreamType &s, UpdateFlags u)