preCICE v3.3.0
Loading...
Searching...
No Matches
GlobalFixtures.cpp
Go to the documentation of this file.
1#include <boost/test/tree/test_unit.hpp>
2#include <boost/test/unit_test.hpp>
3#include <boost/test/unit_test_parameters.hpp>
4#include <boost/test/unit_test_suite.hpp>
5#include <iostream>
6
9
10namespace precice::testing {
11
13{
14 // See if there is a manual override using a log.conf file.
15 auto logConfigs = logging::readLogConfFile("log.conf");
16
17 if (logConfigs.empty()) {
18 // Nothing has been read from log.conf
19 // We configure the log level based on the test framework log level
20
22 config.filter = "%Severity% >= debug";
23
24 const std::string prefix{"%TimeStamp(format=\"%H:%M:%S.%f\")%|%Participant%|%Rank%|%Module%|l%Line%|%Function%|"};
25
26 // Console output
27 config.format = prefix + "%ColorizedSeverity%%Message%";
28 config.type = "stream";
29 config.output = "stdout";
30 logConfigs.push_back(config);
31
32 // File Outputs
33 config.format = prefix + "%Severity%%Message%";
34 config.type = "file";
35 config.output = "test.log";
36 logConfigs.push_back(config);
37
38 // The full debug log
39 config.output = "test.debug.log";
40 config.filter = "%Severity% >= debug";
41 logConfigs.push_back(config);
42 }
43
44 logging::setupLogging(logConfigs);
45 // Lock the logging configuration to prevent systemtests from changing them
47}
48
49} // namespace precice::testing
50
51// Fixtures need to be defined in the global scope
52
54 static void setup()
55 {
56 std::cerr << "Setup up logging\n";
58 }
59};
60
BOOST_TEST_GLOBAL_FIXTURE(PreciceTestLoggingFixture)
void setupLogging(LoggingConfiguration configs, bool enabled)
Configures the logging from a LoggingConfiguration.
LoggingConfiguration readLogConfFile(std::string const &filename)
Reads a log file, returns a logging configuration.
contains the testing framework.
Definition helper.hpp:9
Holds the configuration for one logging backend (sink) and takes care of default values.