From 8a801d58e1f704d7ccfe000f9c0dc26e2dabf165 Mon Sep 17 00:00:00 2001 From: kanschat Date: Fri, 28 Oct 2011 18:43:50 +0000 Subject: [PATCH] provide a simple function call to open and attach logfile git-svn-id: https://svn.dealii.org/trunk@24683 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/tests.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/tests.h b/tests/tests.h index e9c961b03e..90e34769f0 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -33,6 +33,28 @@ // so in each and every testcase using namespace dealii; +// Function for initialize deallog. Normally, it should be called at +// the beginning of main() like +// +// initlog(__FILE__); +// +// This will open the correct output file, divert log output there and +// switch off screen output. If screen output is desired, provide the +// optional second argument as 'true'. +std::string deallogname; +std::ofstream deallogfile; + +inline +void +initlog(const char* filename, bool console=false) +{ + deallogname = JobIdentifier::base_name(filename) + std::string("/output"); + deallogfile.open(deallogname.c_str()); + deallog.attach(deallogfile); + if (!console) + deallog.depth_console(0); +} + // overload floating point output operators for LogStream so that small // numbers below a certain threshold are simply printed as zeros. this removes -- 2.39.5