LogSection.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_LOGGING_LOGSECTION_H_
36 #define _BLAZE_UTIL_LOGGING_LOGSECTION_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <new>
44 #include <sstream>
45 #include <blaze/system/Logging.h>
47 
48 
49 namespace blaze {
50 
51 namespace logging {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
68 {
69  public:
70  //**Constructors********************************************************************************
73  LogSection( LogLevel level );
74  inline LogSection( const LogSection& ls );
76  //**********************************************************************************************
77 
78  //**Destructor**********************************************************************************
81  ~LogSection();
83  //**********************************************************************************************
84 
85  //**Conversion operators************************************************************************
88  inline operator bool() const;
90  //**********************************************************************************************
91 
92  //**Logging functions***************************************************************************
95  template< typename Type > inline void log ( const Type& message );
96  void commit();
98  //**********************************************************************************************
99 
100  private:
101  //**Member variables****************************************************************************
105  std::stringstream message_;
106 
107  //**********************************************************************************************
108 
109  //**Forbidden operations************************************************************************
112  LogSection& operator=( const LogSection& );
113 
114  void* operator new ( std::size_t ) /*throw( std::bad_alloc )*/;
115  void* operator new[]( std::size_t ) /*throw( std::bad_alloc )*/;
116  void* operator new ( std::size_t, const std::nothrow_t& ) /*throw()*/;
117  void* operator new[]( std::size_t, const std::nothrow_t& ) /*throw()*/;
118 
119  void operator delete ( void* ) /*throw()*/;
120  void operator delete[]( void* ) /*throw()*/;
121  void operator delete ( void*, const std::nothrow_t& ) /*throw()*/;
122  void operator delete[]( void*, const std::nothrow_t& ) /*throw()*/;
124  //**********************************************************************************************
125 };
126 //*************************************************************************************************
127 
128 
129 
130 
131 //=================================================================================================
132 //
133 // CONSTRUCTORS
134 //
135 //=================================================================================================
136 
137 //*************************************************************************************************
146  : level_( ls.level_ ) // The logging level of the log section
147 {}
148 //*************************************************************************************************
149 
150 
151 
152 
153 //=================================================================================================
154 //
155 // CONVERSION OPERATOR
156 //
157 //=================================================================================================
158 
159 //*************************************************************************************************
164 inline LogSection::operator bool() const
165 {
166  return true;
167 }
168 //*************************************************************************************************
169 
170 
171 
172 
173 //=================================================================================================
174 //
175 // LOGGING FUNCTIONS
176 //
177 //=================================================================================================
178 
179 //*************************************************************************************************
185 template< typename Type > // Type of the log message
186 inline void LogSection::log( const Type& message )
187 {
188  message_ << message;
189 }
190 //*************************************************************************************************
191 
192 
193 
194 
195 //=================================================================================================
196 //
197 // GLOBAL OPERATORS
198 //
199 //=================================================================================================
200 
201 //*************************************************************************************************
204 template< typename Type >
205 inline LogSection& operator<<( LogSection& logsection, const Type& message );
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
218 template< typename Type > // Type of the log message
219 inline LogSection& operator<<( LogSection& logsection, const Type& message )
220 {
221  logsection.log( message );
222  return logsection;
223 }
224 //*************************************************************************************************
225 
226 } // namespace logging
227 
228 } // namespace blaze
229 
230 #endif
void commit()
Commits the current log message to the log file.
Definition: LogSection.cpp:113
std::stringstream message_
Intermediate buffer for log messages.
Definition: LogSection.h:105
System settings for the logging functionality.
LogSection(LogLevel level)
Constructor for the LogSection class.
Definition: LogSection.cpp:71
LogLevel level_
The logging level of the log section.
Definition: LogSection.h:104
Logging section for (non-)MPI-parallel environments.The LogSection class is an auxiliary helper class...
Definition: LogSection.h:67
LogLevel
Logging levels.The LogLevel type enumeration represents the type of the global logging level...
Definition: LogLevel.h:75
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
LogSection & operator<<(LogSection &logsection, const Type &message)
Global output operator for the LogSection class.
Definition: LogSection.h:219
Header file for the logging levels.
void log(const Type &message)
Logs the given message to the log file.
Definition: LogSection.h:186
~LogSection()
Destructor for the LogSection class.
Definition: LogSection.cpp:89