QMCPACK
OutputManager.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 /** @file OutputManager.h
14  * @brief Declaration of OutputManager class.
15  */
16 #ifndef OUTPUTMANAGER_H
17 #define OUTPUTMANAGER_H
18 
19 #include "InfoStream.h"
20 
21 
22 enum class Verbosity
23 {
24  LOW,
25  HIGH,
26  DEBUG
27 };
28 
29 extern InfoStream infoSummary;
30 extern InfoStream infoLog;
31 extern InfoStream infoError;
32 extern InfoStream infoDebug;
33 
35 {
37 
38 public:
40 
41  void setVerbosity(Verbosity level);
42 
43  bool isActive(Verbosity level) const;
44 
45  bool isDebugActive() const { return isActive(Verbosity::DEBUG); }
46 
47  bool isHighActive() const { return isActive(Verbosity::HIGH); }
48 
49  /// Pause the summary and log streams
50  void pause();
51 
52  /// Resume the summary and log streams
53  void resume();
54 
55  /// Permanently shut off all streams
56  void shutOff();
57 };
58 
60 
61 namespace qmcplusplus
62 {
63 inline std::ostream& app_summary() { return infoSummary.getStream(); }
64 
65 inline std::ostream& app_log() { return infoLog.getStream(); }
66 
67 inline std::ostream& app_error() { return infoError.getStream() << "ERROR "; }
68 
69 inline std::ostream& app_warning() { return infoLog.getStream() << "WARNING "; }
70 
71 inline std::ostream& app_debug_stream() { return infoDebug.getStream(); }
72 
73 // From https://stackoverflow.com/questions/11826554/standard-no-op-output-stream
74 // If debugging is not active, this skips evaluation of the arguments
75 #define app_debug \
76  if (!outputManager.isDebugActive()) {} \
77  else \
78  app_debug_stream
79 
80 
81 // Keep these macros temporarily until all output uses streams
82 #define LOGMSG(msg) \
83  { \
84  qmcplusplus::app_log() << msg << std::endl; \
85  }
86 #define ERRORMSG(msg) \
87  { \
88  app_error() << msg << std::endl; \
89  }
90 #define WARNMSG(msg) \
91  { \
92  app_warning() << msg << std::endl; \
93  }
94 #ifdef PRINT_DEBUG
95 #define DEBUGMSG(msg) \
96  { \
97  app_debug() << msg << std::endl; \
98  }
99 #else
100 #define DEBUGMSG(msg)
101 #endif
102 
103 #define XMLReport(msg)
104 
105 }; // namespace qmcplusplus
106 
107 #endif
void pause()
Pause the summary and log streams.
Interface to output streams.
Definition: InfoStream.h:28
Verbosity
Definition: OutputManager.h:22
std::ostream & app_warning()
Definition: OutputManager.h:69
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::ostream & getStream(const std::string &tag="")
returns current stream
Definition: InfoStream.h:37
bool isHighActive() const
Definition: OutputManager.h:47
InfoStream infoSummary
InfoStream infoDebug
std::ostream & app_log()
Definition: OutputManager.h:65
void shutOff()
Permanently shut off all streams.
Verbosity global_verbosity_level
Definition: OutputManager.h:36
std::ostream & app_summary()
Definition: OutputManager.h:63
std::ostream & app_error()
Definition: OutputManager.h:67
InfoStream infoLog
void resume()
Resume the summary and log streams.
OutputManagerClass(Verbosity level=Verbosity::LOW)
Definition: OutputManager.h:39
Declaration of InfoStream class.
bool isDebugActive() const
Definition: OutputManager.h:45
OutputManagerClass outputManager
InfoStream infoError
bool isActive(Verbosity level) const
std::ostream & app_debug_stream()
Definition: OutputManager.h:71
void setVerbosity(Verbosity level)