ug4
|
#include <log.h>
Public Member Functions | |
std::ostream & | debug_logger () |
returns the debug output stream More... | |
bool | enable_file_output (bool bEnable, const char *filename="uglog.log") |
enables or disables file output. More... | |
bool | enable_terminal_output (bool bEnable) |
enables or disables terminal output. More... | |
std::ostream & | error_logger () |
returns the error output stream More... | |
void | flush () |
void | flush_error_log () |
outputs all gathered error-logs to the standard logger and clears the error log. More... | |
int | get_debug_level (const char *debugID) const |
returns the debug level of debugID More... | |
int | get_debug_level (DebugID &debugID) const |
returns the debug level of debugID More... | |
int | get_debug_level_noninline (const char *debugID) const |
returns the debug level of debugID More... | |
int | get_output_process () |
returns the rank of the current output-process or -1 if all procs perform output. More... | |
int | get_process_rank () |
returns the process rank of the underlying process (same as pcl::ProcRank) More... | |
std::string | get_registered_debug_IDs () |
returns the debug level of debugID More... | |
bool | is_output_process () |
returns true if the current process is an output process. More... | |
std::ostream & | logger () |
returns the normal output stream More... | |
bool | rename_log_file (const char *newname) |
renames output file if opened. More... | |
bool | set_debug_level (const char *debugID, int level) |
returns the debug level of debugID More... | |
bool | set_debug_level (DebugID &debugID, int level) |
sets the debug level of debugID More... | |
bool | set_debug_level_noninline (const char *debugID, int level) |
bool | set_debug_levels (int lev) |
sets the debug level of all tags to 'lev' More... | |
void | set_output_process (int procRank) |
sets the output-process in a parallel environment. Default is 0. More... | |
~LogAssistant () | |
flushes all buffers before deletion More... | |
Static Public Member Functions | |
static LogAssistant & | instance () |
returns a reference to the single instance of LogAssistant More... | |
Protected Member Functions | |
bool | open_logfile () |
opens the local logFile, if the process is the output-process More... | |
void | update_ostream () |
updates and sets stream buffers based on current options. More... | |
Private Member Functions | |
void | init () |
Performs some initialization. More... | |
LogAssistant () | |
Constructor, resets all debug levels to -1. More... | |
LogAssistant (const LogAssistant &) | |
Prevent copying through private copy constructor. More... | |
Private Attributes | |
std::streambuf * | m_emptyBuf |
EmptyStreamBuffer | m_emptyBufInst |
std::stringstream | m_errStream |
std::streambuf * | m_fileBuf |
bool | m_fileOutputEnabled |
std::ofstream | m_fileStream |
std::streambuf * | m_logBuf |
std::string | m_logFileName |
int | m_outputProc |
std::streambuf * | m_splitBuf |
OStreamBufferSplitter | m_splitBufInst |
bool | m_terminalOutputEnabled |
This class provides infrastructure for logging. It separates the log messages in different levels:
logger() returns the output stream for normal User information output. debug_logger() returns the output stream for debug informations.
Debug messages are grouped by tags and debug levels. It is intended, that only messages are printed, when the current level is equal or greater than the debug level chosen in the code.
Please note that this class operates on std::clog. Thus, if output-options are changed (e.g. file-logging enabled) the stream buffer on which clog operates will change too.
ug::LogAssistant::~LogAssistant | ( | ) |
flushes all buffers before deletion
References flush(), and m_fileStream.
|
private |
Constructor, resets all debug levels to -1.
Constructor is private since only one instance of LogAssistant may exist.
|
private |
Prevent copying through private copy constructor.
|
inline |
returns the debug output stream
bool ug::LogAssistant::enable_file_output | ( | bool | bEnable, |
const char * | filename = "uglog.log" |
||
) |
enables or disables file output.
a filename can be specified. Default is 'uglog.log'. Please note that only the filename given at the first call is considered. Filelogging is disabled by default.
References m_fileOutputEnabled, m_fileStream, m_logFileName, open_logfile(), PROFILE_FUNC, and update_ostream().
Referenced by ugshell_main().
bool ug::LogAssistant::enable_terminal_output | ( | bool | bEnable | ) |
enables or disables terminal output.
terminal output is enbled by default.
References m_terminalOutputEnabled, PROFILE_FUNC, and update_ostream().
Referenced by ugshell_main().
|
inline |
returns the error output stream
Note that error-logs are not immediately visible. Instead they are gathered and can be printed in one block using LogAssistant::flush_error_log().
References m_errStream.
void ug::LogAssistant::flush | ( | ) |
References ug::OStreamBufferSplitter::flush(), logger(), m_fileStream, m_splitBufInst, and m_terminalOutputEnabled.
Referenced by pcl::MPIErrorHandler(), ug::print_mark(), rename_log_file(), ug::Progress::setD(), ug::ParallelProgress::setD(), ug::script::UGLuaErrLog(), ug::script::UGLuaWrite(), and ~LogAssistant().
void ug::LogAssistant::flush_error_log | ( | ) |
outputs all gathered error-logs to the standard logger and clears the error log.
References logger(), and m_errStream.
Referenced by Java_edu_gcsc_vrl_ug_UG__1ugInit(), ug::vrl::registry2NativeAPI(), and ug::UGFinalizeNoPCLFinalize().
|
inline |
returns the debug level of debugID
References ug::DebugIDManager::get_debug_level(), and ug::GetDebugIDManager().
|
inline |
returns the debug level of debugID
References ug::DebugIDManager::get_debug_level(), and ug::GetDebugIDManager().
int ug::LogAssistant::get_debug_level_noninline | ( | const char * | debugID | ) | const |
returns the debug level of debugID
References ug::DebugIDManager::get_debug_level(), and ug::GetDebugIDManager().
|
inline |
returns the rank of the current output-process or -1 if all procs perform output.
References m_outputProc.
Referenced by ug::LogIndexLayoutOnAllProcs(), ug::IApproximationSpace::print_layout_statistic(), ug::print_mark(), pcl::SendRecvBuffersMatch(), and pcl::SendRecvListsMatch().
int ug::LogAssistant::get_process_rank | ( | ) |
returns the process rank of the underlying process (same as pcl::ProcRank)
References pcl::ProcRank().
|
inline |
returns the debug level of debugID
References ug::DebugIDManager::get_registered_debug_IDs(), and ug::GetDebugIDManager().
|
private |
Performs some initialization.
References m_emptyBuf, m_emptyBufInst, m_fileBuf, m_fileStream, m_logBuf, m_splitBuf, m_splitBufInst, PROFILE_FUNC, ug::OStreamBufferSplitter::set_buffers(), set_debug_levels(), and update_ostream().
Referenced by instance().
|
static |
returns a reference to the single instance of LogAssistant
References init().
Referenced by ug::GetLogAssistant().
bool ug::LogAssistant::is_output_process | ( | ) |
returns true if the current process is an output process.
This is always true, if the application is executed in a serial environment.
References m_outputProc, and pcl::ProcRank().
Referenced by open_logfile(), update_ostream(), ug::VTKOutput< TDim >::write_pvtu(), ug::VTKOutput< TDim >::write_subset_pvd(), ug::VTKOutput< TDim >::write_time_processwise_pvd(), ug::VTKOutput< TDim >::write_time_pvd(), and ug::VTKOutput< TDim >::write_time_pvd_subset().
|
inline |
returns the normal output stream
Referenced by flush(), and flush_error_log().
|
protected |
opens the local logFile, if the process is the output-process
References is_output_process(), m_fileOutputEnabled, m_fileStream, m_logFileName, PROFILE_FUNC, and UG_LOG.
Referenced by enable_file_output(), and update_ostream().
bool ug::LogAssistant::rename_log_file | ( | const char * | newname | ) |
renames output file if opened.
References flush(), m_fileStream, m_logFileName, PROFILE_FUNC, and UG_LOG.
|
inline |
returns the debug level of debugID
References ug::GetDebugIDManager(), and ug::DebugIDManager::set_debug_level().
|
inline |
sets the debug level of debugID
References ug::GetDebugIDManager(), and ug::DebugIDManager::set_debug_level().
Referenced by ug::bridge::SetDebugLevel().
bool ug::LogAssistant::set_debug_level_noninline | ( | const char * | debugID, |
int | level | ||
) |
References ug::GetDebugIDManager(), and ug::DebugIDManager::set_debug_level().
|
inline |
sets the debug level of all tags to 'lev'
References ug::GetDebugIDManager(), and ug::DebugIDManager::set_debug_levels().
Referenced by init().
void ug::LogAssistant::set_output_process | ( | int | procRank | ) |
sets the output-process in a parallel environment. Default is 0.
pass a procRank of -1 to enable output on all processes.
References m_outputProc, pcl::NumProcs(), UG_LOG, and update_ostream().
Referenced by ug::LogIndexLayoutOnAllProcs(), ug::print_mark(), ug::UGInit(), and ugshell_main().
|
protected |
updates and sets stream buffers based on current options.
Note that this method changes the buffer on which clog works.
References is_output_process(), m_emptyBuf, m_fileBuf, m_fileOutputEnabled, m_logBuf, m_splitBuf, m_terminalOutputEnabled, and open_logfile().
Referenced by enable_file_output(), enable_terminal_output(), init(), and set_output_process().
|
private |
Referenced by init(), and update_ostream().
|
private |
Referenced by init().
|
private |
Referenced by error_logger(), and flush_error_log().
|
private |
Referenced by init(), and update_ostream().
|
private |
Referenced by enable_file_output(), open_logfile(), and update_ostream().
|
private |
Referenced by enable_file_output(), flush(), init(), open_logfile(), rename_log_file(), and ~LogAssistant().
|
private |
Referenced by init(), and update_ostream().
|
private |
Referenced by enable_file_output(), open_logfile(), and rename_log_file().
|
private |
Referenced by get_output_process(), is_output_process(), and set_output_process().
|
private |
Referenced by init(), and update_ostream().
|
private |
|
private |
Referenced by enable_terminal_output(), flush(), and update_ostream().