MoorDyn
Public Member Functions | List of all members
moordyn::Log Class Reference

A Logging utility. More...

#include <Log.hpp>

Public Member Functions

 Log (const int verbosity=MOORDYN_MSG_LEVEL, const int log_file_level=MOORDYN_DBG_LEVEL)
 Constructor. More...
 
 ~Log ()
 Destructor.
 
MultiStreamCout (const int level=MOORDYN_MSG_LEVEL) const
 Get a stream to log data. More...
 
int GetVerbosity () const
 Get the verbosity level. More...
 
void SetVerbosity (const int verbosity)
 Set the verbosity level. More...
 
int GetLogLevel () const
 Get the log file printing level. More...
 
void SetLogLevel (const int level)
 Set the log file printing level. More...
 
const char * GetFile () const
 Get the log file path. More...
 
void SetFile (const char *file_path)
 Set the log file path. More...
 

Detailed Description

A Logging utility.

This class is a sensible replacement for std::cout and std::cerr ofstream entities, providing the appropriate streaming channel to each entity

Constructor & Destructor Documentation

◆ Log()

moordyn::Log::Log ( const int  verbosity = MOORDYN_MSG_LEVEL,
const int  log_file_level = MOORDYN_DBG_LEVEL 
)

Constructor.

Parameters
verbosityThe verbosity level (see Moordyn_log)
log_file_levelThe same than verbosity, but for the log file (if any is open with SetFile(). It is disabled by default)
Exceptions
moordyn::mem_errorIf the inner streamer cannot be built

Member Function Documentation

◆ Cout()

MultiStream & moordyn::Log::Cout ( const int  level = MOORDYN_MSG_LEVEL) const

Get a stream to log data.

Whether the message is logged, and where, depends on the verbosity level

Parameters
levelMessage level
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFile()

const char * moordyn::Log::GetFile ( ) const

Get the log file path.

Returns
The log file path, an empty string if no log file is considered
Here is the call graph for this function:

◆ GetLogLevel()

int moordyn::Log::GetLogLevel ( ) const
inline

Get the log file printing level.

Returns
The log file printing level (see Moordyn_log)

◆ GetVerbosity()

int moordyn::Log::GetVerbosity ( ) const
inline

Get the verbosity level.

Returns
The verbosity level (see Moordyn_log)

◆ SetFile()

void moordyn::Log::SetFile ( const char *  file_path)

Set the log file path.

This method will immediately try to open such file for writing.

Parameters
file_pathThe log file path
Note
To disable logging after open a file with this method it is better to use SetLogLevel()
Exceptions
moordyn::output_file_errorIf the output file cannot be opened/created at file_path
Here is the call graph for this function:

◆ SetLogLevel()

void moordyn::Log::SetLogLevel ( const int  level)
inline

Set the log file printing level.

Parameters
levelThe log file printing level (see Moordyn_log)

◆ SetVerbosity()

void moordyn::Log::SetVerbosity ( const int  verbosity)
inline

Set the verbosity level.

Parameters
verbosityThe verbosity level (see Moordyn_log)

The documentation for this class was generated from the following files: