Tomographer  v5.4
Tomographer C++ Framework Documentation
boost_test_logger.h
Go to the documentation of this file.
1 /* This file is part of the Tomographer project, which is distributed under the
2  * terms of the MIT license.
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2016 ETH Zurich, Institute for Theoretical Physics, Philippe Faist
7  * Copyright (c) 2017 Caltech, Institute for Quantum Information and Matter, Philippe Faist
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  */
27 
28 
29 #ifndef TOMOGRAPHER_TOOLS_BOOST_TEST_LOGGER_H
30 #define TOMOGRAPHER_TOOLS_BOOST_TEST_LOGGER_H
31 
40 
41 
42 namespace Tomographer { namespace Logger {
43 
44 class BoostTestLogger;
45 
46 // traits for BoostTestLogger
47 template<>
48 struct TOMOGRAPHER_EXPORT LoggerTraits<BoostTestLogger> : DefaultLoggerTraits
49 {
50  enum {
51  IsThreadSafe = 0, StaticMinimumImportanceLevel = -1
52  };
53 };
54 
64 class TOMOGRAPHER_EXPORT BoostTestLogger : public Tomographer::Logger::LoggerBase<BoostTestLogger>
65 {
66 public:
69  {
70  }
71  inline void setLevel(int level)
72  {
73  // call the protected LoggerBase<StderrLogger>::setLogLevel()
74  setLogLevel(level);
75  }
76  inline void emitLog(int level, const char * origin,
77  const std::string & msg)
78  {
79  BOOST_TEST_MESSAGE("(" << Tomographer::Logger::LogLevel(level) << ")" << "[" << origin << "] " << msg) ;
80  }
81 };
82 
83 
84 
85 
86 } } // namespaces
87 
88 
89 
90 #endif
Base namespace for the Tomographer project.
Definition: densellh.h:45
A logger we can use in tests, which calls BOOST_TEST_MESSAGE()
Object which stores a log level and can initialize from a string.
Definition: loggers.h:158
Base logger class.
Definition: loggers.h:444
STL class.
Default traits for Logger implementations.
Definition: loggers.h:288
Traits template struct to be specialized for specific Logger implementations.
Definition: loggers.h:351
Debug logging level.
Definition: loggers.h:112
Utilities for logging messages.