OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
The object FcstUtilities::log should be used throughout OpenFCST for console logging. More...
#include <logging.h>
Public Member Functions | |
FCSTLogStream (std::ostream &stream) | |
Standard constructor, since we intend to provide an object deallog in the library. More... | |
~FCSTLogStream () | |
Destructor. More... | |
void | attach (std::ostream &o, const bool print_job_id=true) |
Enable output to a second stream, o , usually an output file. More... | |
void | detach () |
Disable output to the second stream. More... | |
std::ostream & | get_file_stream () |
Setup the logstream for regression test mode. More... | |
bool | has_file () const |
void | push (const std::string &text) |
Push another prefix on the stack. More... | |
void | pop () |
Remove the last prefix added with push(). More... | |
unsigned int | depth_console (const unsigned int n) |
Maximum number of levels to be printed on the console. More... | |
unsigned int | depth_file (const unsigned int n) |
Maximum number of levels to be written to the log file. More... | |
template<typename T > | |
const FCSTLogStream & | operator<< (const T &t) const |
Output a constant something through this stream. More... | |
const FCSTLogStream & | operator<< (std::ostream &(*p)(std::ostream &)) const |
Treat ostream manipulators. More... | |
Private Attributes | |
std::ostream & | output_stream |
Determine an estimate for the memory consumption (in bytes) of this object. More... | |
std::ostream * | file |
Pointer to a stream, where a copy of the output is to go to. More... | |
The object FcstUtilities::log should be used throughout OpenFCST for console logging.
When OpenFCST is compiled with PETSC/MPI the logging class is changed to accommodate logging from multiple processes.
FcstUtilities::FCSTLogStream::FCSTLogStream | ( | std::ostream & | stream | ) |
Standard constructor, since we intend to provide an object deallog
in the library.
Set the standard output stream to std::cerr
.
FcstUtilities::FCSTLogStream::~FCSTLogStream | ( | ) |
Destructor.
void FcstUtilities::FCSTLogStream::attach | ( | std::ostream & | o, |
const bool | print_job_id = true |
||
) |
Enable output to a second stream, o
, usually an output file.
The optional argument print_job_id
is not used and it is maintained here to keep the same format as deal LogStream.
|
inline |
Maximum number of levels to be printed on the console.
This function allows to restrict console output to the upmost levels of iterations. Only output with less than n
prefixes is printed. By calling this function with n=0
, no console output will be written.
The previous value of this parameter is returned.
|
inline |
Maximum number of levels to be written to the log file.
The functionality is the same as depth_console
, nevertheless, this function should be used with care, since it may spoile the value of a log file.
The previous value of this parameter is returned.
void FcstUtilities::FCSTLogStream::detach | ( | ) |
Disable output to the second stream.
You may want to call close
on the stream that was previously attached to this object.
|
inline |
Setup the logstream for regression test mode.
This sets the parameters #double_threshold, #float_threshold, and #offset to nonzero values. The exact values being used have been determined experimentally and can be found in the source code.
Called with an argument false
, switches off test mode and sets all involved parameters to zero. Gives the default stream (std_out
). Gives the file stream.
|
inline |
|
inline |
Output a constant something through this stream.
This function must be const
so that member objects of this type can also be used from const
member functions of the surrounding class.
|
inline |
Treat ostream manipulators.
This function must be const
so that member objects of this type can also be used from const
member functions of the surrounding class.
Note that compilers want to see this treated differently from the general template above since functions like std::endl
are actually overloaded and can't be bound directly to a template type.
|
inline |
Remove the last prefix added with push().
|
inline |
Push another prefix on the stack.
Prefixes are automatically separated by a colon and there is a double colon after the last prefix.
A simpler way to add a prefix (without the manual need to add the corresponding pop()) is to use the Prefix class.
|
private |
Pointer to a stream, where a copy of the output is to go to.
Usually, this will be a file stream.
You can set and reset this stream by the attach
function.
|
private |
Determine an estimate for the memory consumption (in bytes) of this object.
Since sometimes the size of objects can not be determined exactly (for example: what is the memory consumption of an STL std::map
type with a certain number of elements?), this is only an estimate. however often quite close to the true value. Reference to the stream we want to write to.