33 #ifndef __H__UG__COMMON__LOG__
34 #define __H__UG__COMMON__LOG__
110 bool enable_file_output(
bool bEnable,
const char* filename =
"uglog.log");
113 bool rename_log_file(
const char * newname);
117 bool enable_terminal_output(
bool bEnable);
120 inline std::ostream& debug_logger();
123 inline std::ostream& logger();
128 inline std::ostream& error_logger();
131 void flush_error_log();
150 int get_debug_level_noninline(
const char *debugID)
const;
165 bool set_debug_level_noninline(
const char* debugID,
int level);
175 void set_output_process(
int procRank);
178 inline int get_output_process();
182 bool is_output_process();
185 int get_process_rank();
192 void update_ostream();
232 inline std::string
ConvertNumber (uint64_t size,
unsigned int width,
233 unsigned int numDisplayedDigits);
237 unsigned int numDisplayedDigits);
275 #ifdef UG_ENABLE_DEBUG_LOGS
276 #define UG_SET_DEBUG_LEVEL(__debugID__, level) {ug::GetDebugIDManager().set_debug_level(__debugID__, level);}
277 #define UG_RESET_DEBUG_LEVELS() {ug::GetDebugIDManager().set_debug_levels(-1);}
278 #define UG_SET_DEBUG_LEVELS(level) {ug::GetDebugIDManager().set_debug_levels(level);}
279 #define UG_DEBUG_BEGIN(__debugID__, level) { if(ug::GetDebugIDManager().get_debug_level(__debugID__) >= level) {
280 #define UG_DEBUG_END(__debugID__, level) }; }
281 #define IF_DEBUG(__debugID__, level) if(ug::GetDebugIDManager().get_debug_level(__debugID__) >= level)
283 #define UG_DLOG(__debugID__, level, msg) \
284 {if(ug::GetDebugIDManager().get_debug_level(__debugID__) >= level)\
285 {ug::GetLogAssistant().debug_logger() << msg; ug::GetLogAssistant().debug_logger().flush();}}
287 #define UG_DLOGN(__debugID__, level, msg) UG_DLOG(__debugID__, level, msg << "\n");
289 #define UG_DLOG_ALL_PROCS(__debugID__, level, msg) \
290 {if(ug::GetDebugIDManager().get_debug_level(__debugID__) >= level)\
291 {ug::LogAssistant& la = ug::GetLogAssistant(); int op = la.get_output_process();\
292 la.set_output_process(-1); la.debug_logger() << "[Proc " << la.get_process_rank() << "]: "\
293 << msg << std::flush; la.set_output_process(op);}}
295 #define UG_SET_DEBUG_LEVEL(__debugID__, level) {}
296 #define UG_RESET_DEBUG_LEVELS() {}
297 #define UG_SET_DEBUG_LEVELS(level) {}
298 #define UG_DLOG(__debugID__, level, msg) {}
299 #define UG_DLOGN(__debugID__, level, msg) {}
300 #define UG_DLOG_ALL_PROCS(__debugID__, level, msg) {}
301 #define UG_DEBUG_BEGIN(__debugID__, level) { if(1==0) {
302 #define UG_DEBUG_END(__debugID__, level) }; }
303 #define IF_DEBUG(__debugID__, level) if(1==0)
315 #define UG_ENABLE_WARNINGS
317 #undef UG_ENABLE_WARNINGS
327 #ifdef UG_ENABLE_WARNINGS
328 #define UG_WARNING(msg) {ug::GetLogAssistant().logger() << "UG_WARNING in "\
329 << __FILE__ << " at line " << __LINE__ << ": " \
330 << msg << std::flush;}
332 #define UG_WARNING(msg) {}
343 #ifdef UG_ENABLE_WARNINGS
344 #define UG_COND_WARNING(cond, msg) { if (cond) {ug::GetLogAssistant().logger() << "UG_WARNING in "\
345 << __FILE__ << " at line " << __LINE__ << ": " \
346 << msg << std::flush;} }
348 #define UG_COND_WARNING(cond, msg) {}
361 #define VRL_LOG(msg) {std::stringstream __ss; __ss << "" << msg;\
362 ug::vrl::MessageBuffer::addMessage(__ss.str());}
367 #define UG_LOG(msg) {ug::GetLogAssistant().logger() << msg << std::flush; VRL_LOG(msg);}
368 #define UG_COND_LOG(cond, msg) { if (cond) { UG_LOG(msg); } }
369 #define UG_LOGN(msg) UG_LOG(msg << "\n")
370 #define UG_COND_LOGN(cond, msg) { if (cond) { UG_LOGN(msg); } }
371 #define UG_LOG_ALL_PROCS(msg) {ug::LogAssistant& la = ug::GetLogAssistant();\
372 int op = la.get_output_process(); la.set_output_process(-1);\
373 la.logger() << "[Proc " << std::setw(3) << la.get_process_rank() << "]: "\
374 << msg << std::flush; VRL_LOG(msg); la.set_output_process(op);}
383 #define UG_ERR_LOG(msg) {ug::GetLogAssistant().error_logger() << msg; VRL_LOG(msg);}
Definition: debug_id.h:94
Used by EmptyStream, to send tokens into nirvana!
Definition: empty_stream.h:50
std::streambuf * m_emptyBuf
Definition: log.h:209
OStreamBufferSplitter m_splitBufInst
Definition: log.h:215
bool m_terminalOutputEnabled
Definition: log.h:221
std::stringstream m_errStream
Definition: log.h:219
bool set_debug_level(DebugID &debugID, int level)
sets the debug level of debugID
Definition: log.h:154
bool m_fileOutputEnabled
Definition: log.h:222
EmptyStreamBuffer m_emptyBufInst
Definition: log.h:214
std::streambuf * m_logBuf
Definition: log.h:210
int get_debug_level(const char *debugID) const
returns the debug level of debugID
Definition: log.h:145
std::streambuf * m_splitBuf
Definition: log.h:212
bool set_debug_level(const char *debugID, int level)
returns the debug level of debugID
Definition: log.h:160
std::string m_logFileName
Definition: log.h:217
bool set_debug_levels(int lev)
sets the debug level of all tags to 'lev'
Definition: log.h:134
int m_outputProc
Definition: log.h:224
std::ofstream m_fileStream
Definition: log.h:218
int get_debug_level(DebugID &debugID) const
returns the debug level of debugID
Definition: log.h:140
std::string get_registered_debug_IDs()
returns the debug level of debugID
Definition: log.h:168
std::streambuf * m_fileBuf
Definition: log.h:211
forwards data written to this stream-buffer to other stream buffers.
Definition: ostream_buffer_splitter.h:51
const uint64 UNIT_PETA_SI
Definition: log.h:74
const uint64 UNIT_KILO_SI
Definition: log.h:70
LogAssistant & GetLogAssistant()
Definition: log_impl.h:69
bool set_debug_level(uint32 debugIDhash, int level)
sets the debug level of debugIDhash if registered to 'level'
Definition: debug_id.h:151
const uint64 UNIT_PETA
Definition: log.h:66
const uint64 UNIT_GIGA_SI
Definition: log.h:72
std::string ConvertNumberSI(uint64_t size, unsigned int width, unsigned int numDisplayedDigits)
returns number 'size' in a more human readable format (using SI prefixes)
Definition: log_impl.h:132
#define UG_API
Definition: ug_config.h:65
int get_debug_level(uint32 debugIDhash) const
returns the debug level of debugIDhash, -1 if not found
Definition: debug_id.h:143
const uint64 UNIT_TERA
Definition: log.h:65
bool set_debug_levels(int lev)
sets the debug level of all registered debugIDs to 'lev'
Definition: debug_id.cpp:64
const uint64 UNIT_GIGA
Definition: log.h:64
std::string get_registered_debug_IDs() const
returns a string describing all registered debugIDs.
Definition: debug_id.h:208
const uint64 UNIT_EXA_SI
Definition: log.h:75
const uint64 UNIT_MEGA
Definition: log.h:63
const uint64 UNIT_KILO
Definition: log.h:62
const uint64 UNIT_EXA
Definition: log.h:67
DebugIDManager & GetDebugIDManager()
Definition: debug_id.h:231
const uint64 UNIT_TERA_SI
Definition: log.h:73
const uint64 UNIT_MEGA_SI
Definition: log.h:71
std::string ConvertNumber(uint64_t size, unsigned int width, unsigned int numDisplayedDigits)
returns number 'size' in a more human readable format (using IEC binary prefixes)
Definition: log_impl.h:81
ugtypes::uint64_t uint64
Definition: types.h:117