mlpack
Static Public Member Functions | Static Public Attributes | List of all members
mlpack::Log Class Reference

Provides a convenient way to give formatted output. More...

#include <log.hpp>

Collaboration diagram for mlpack::Log:
Collaboration graph
[legend]

Static Public Member Functions

static void Assert (bool condition, const std::string &message="Assert Failed.")
 Checks if the specified condition is true. More...
 

Static Public Attributes

static MLPACK_EXPORT util::NullOutStream Debug = NullOutStream()
 MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows compiler. More...
 
static MLPACK_EXPORT util::PrefixedOutStream Info
 Prints informational messages if –verbose is specified, prefixed with [INFO ]. More...
 
static MLPACK_EXPORT util::PrefixedOutStream Warn
 Prints warning messages prefixed with [WARN ]. More...
 
static MLPACK_EXPORT util::PrefixedOutStream Fatal
 Prints fatal messages prefixed with [FATAL], then terminates the program. More...
 
static std::ostream & cout
 Reference to cout, if necessary.
 

Detailed Description

Provides a convenient way to give formatted output.

The Log class has four members which can be used in the same way ostreams can be used:

Each of these will prefix a tag to the output (for easy filtering), and the fatal output will terminate the program when a newline is encountered. An example is given below.

Log::Info << "Checking a condition." << std::endl;
if (!someCondition())
Log::Warn << "someCondition() is not satisfied!" << std::endl;
Log::Info << "Checking an important condition." << std::endl;
if (!someImportantCondition())
{
Log::Fatal << "someImportantCondition() is not satisfied! Terminating.";
Log::Fatal << std::endl;
}

Any messages sent to Log::Debug will not be shown when compiling in non-debug mode. Messages to Log::Info will only be shown when the –verbose flag is given to the program (or rather, the IO class).

See also
PrefixedOutStream, NullOutStream, IO

Member Function Documentation

◆ Assert()

void Log::Assert ( bool  condition,
const std::string &  message = "Assert Failed." 
)
static

Checks if the specified condition is true.

If not, halts program execution and prints a custom error message. Does nothing in non-debug mode.

Member Data Documentation

◆ Debug

NullOutStream Log::Debug = NullOutStream()
static

MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows compiler.

Dumps debug output into the bit nether regions.

◆ Fatal

PrefixedOutStream Log::Fatal
static
Initial value:
= PrefixedOutStream(MLPACK_CERR_STREAM,
BASH_RED "[FATAL] " BASH_CLEAR, false, true )

Prints fatal messages prefixed with [FATAL], then terminates the program.

◆ Info

PrefixedOutStream Log::Info
static
Initial value:
= PrefixedOutStream(MLPACK_COUT_STREAM,
BASH_GREEN "[INFO ] " BASH_CLEAR, true , false)

Prints informational messages if –verbose is specified, prefixed with [INFO ].

◆ Warn

PrefixedOutStream Log::Warn
static
Initial value:
= PrefixedOutStream(MLPACK_COUT_STREAM,
BASH_YELLOW "[WARN ] " BASH_CLEAR, false, false)

Prints warning messages prefixed with [WARN ].


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