Sapphire++
 v1.3.0-121-g2682132
Loading...
Searching...
No Matches
sapphirepp::Utils::SapphireppLogStream Class Reference

LogStream for Sapphire+⁠+ More...

#include <sapphirepp-logstream.h>

Inheritance diagram for sapphirepp::Utils::SapphireppLogStream:
[legend]
Collaboration diagram for sapphirepp::Utils::SapphireppLogStream:
[legend]

Public Member Functions

 SapphireppLogStream ()
 Constructor.
 ~SapphireppLogStream ()
 Destructor.
void init (const unsigned int depth_console=2, const bool enable_mpi_output=false)
 Initialize the log stream.
void init (const int argc, const char *const argv[])
 Initialize the log stream with command line options.
void init_parse (const int argc, const char *const argv[], std::string &parameter_filename, bool &resume)
 Initialize the log stream and parse command line options.
void attach_file (const std::string &filepath, const unsigned int depth_file, const bool enable_mpi_output=false)
 Attach a logfile to the stream.
void print_error (const std::exception &exc)
 Prints an error message to std:err and this LogStream.
void print_warning (const std::string &warning)
 Prints a warning to std:err and this LogStream.
unsigned int get_verbosity_console ()
 Get the verbosity of the console output.
unsigned int get_verbosity_file ()
 Get the verbosity of the file output.
std::ostream & to_ostream (const unsigned int verbosity=3)
 Conversion to std::ostream.
dealii::ConditionalOStream to_condition_ostream (const unsigned int verbosity=3)
 Conversion to ConditionalOStream.
 operator std::ostream & ()
 Conversion operator to std::ostream.
 operator dealii::ConditionalOStream ()
 Conversion operator to ConditionalOStream.

Detailed Description

LogStream for Sapphire+⁠+

The Stream is prefixed with sapphirepp. In case of parallel execution, all but the first process are prefixed with mpi<rank>.

For more details see LogStream documentation

Member Function Documentation

◆ attach_file()

void sapphirepp::Utils::SapphireppLogStream::attach_file ( const std::string & filepath,
const unsigned int depth_file,
const bool enable_mpi_output = false )

Attach a logfile to the stream.

Parameters
filepathPath to the logfile
depth_fileThe verbosity of the file output
enable_mpi_outputEnable output of all mpi processes

◆ get_verbosity_console()

unsigned int sapphirepp::Utils::SapphireppLogStream::get_verbosity_console ( )

Get the verbosity of the console output.

Returns
unsigned int verbosity of the console output

◆ get_verbosity_file()

unsigned int sapphirepp::Utils::SapphireppLogStream::get_verbosity_file ( )

Get the verbosity of the file output.

Returns
unsigned int verbosity of the file output

◆ init() [1/2]

void sapphirepp::Utils::SapphireppLogStream::init ( const int argc,
const char *const argv[] )

Initialize the log stream with command line options.

This function must only be called after MPI initialization. To show all options use the --help/-h flag.

Parameters
argcNumber of commandline arguments
argvCommandline arguments

◆ init() [2/2]

void sapphirepp::Utils::SapphireppLogStream::init ( const unsigned int depth_console = 2,
const bool enable_mpi_output = false )

Initialize the log stream.

This function must only be called after MPI initialization. It prefixes the log stream with MPI<rank> for all but the first rank. In addition, it shows a start-up message.

Parameters
depth_consoleThe verbosity of the console output
  • 0 silence the program
  • 1 shows only the start-up message and warnings
  • 2 show progress
  • >2 show different levels of debug messages
enable_mpi_outputIf true, all mpi processes will output to the console, otherwise only the first process will show messages

◆ init_parse()

void sapphirepp::Utils::SapphireppLogStream::init_parse ( const int argc,
const char *const argv[],
std::string & parameter_filename,
bool & resume )

Initialize the log stream and parse command line options.

This function must only be called after MPI initialization. To show all options use the --help/-h flag.

Parameters
argcNumber of commandline arguments
argvCommandline arguments
parameter_filenameParameter file name
resumeResume simulation from checkpoint?

◆ print_error()

void sapphirepp::Utils::SapphireppLogStream::print_error ( const std::exception & exc)

Prints an error message to std:err and this LogStream.

This has the advantage, that error messages are also saved in the logfile.

Parameters
excException

◆ print_warning()

void sapphirepp::Utils::SapphireppLogStream::print_warning ( const std::string & warning)

Prints a warning to std:err and this LogStream.

The warning is shown for verbosity > 0.

Parameters
warningWarning message

◆ to_condition_ostream()

dealii::ConditionalOStream sapphirepp::Utils::SapphireppLogStream::to_condition_ostream ( const unsigned int verbosity = 3)

Conversion to ConditionalOStream.

Returns either file or console output stream dependent on verbosity. If the target verbosity is larger then the logstream verbosity, the result will be silenced.

Parameters
verbosityTarget verbosity of the output
Returns
dealii::ConditionalOStream ConditionalOStream

◆ to_ostream()

std::ostream & sapphirepp::Utils::SapphireppLogStream::to_ostream ( const unsigned int verbosity = 3)

Conversion to std::ostream.

Returns either file or console output stream dependent on verbosity. If the target verbosity is larger then the logstream verbosity, return an empty stream.

Parameters
verbosityTarget verbosity of the output
Returns
std::ostream&

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