SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes
Pitch Class Reference

Redirect output to std::out, std::cerr or file depending on severity. More...

#include <Pitch.hh>

Public Types

enum  errorLevel {
  debug, info, warning, error,
  fatal, log
}
 Error level that determines where the output goes. More...
 

Static Public Member Functions

static std::ostream & mout ()
 Shorthand that returns output to Pitch::mout(Pitch::debug) More...
 
static std::ostream & mout (errorLevel level)
 Returns a reference to the ostream corresponding to the errorLevel. More...
 
static std::ostream & mout (Exceptions::exceptionLevel level)
 Returns a reference to the ostream corresponding to the exceptionLevel. More...
 
static void setAnOutput (errorLevel level, std::ostream &out)
 Set the ostream for a given error level (Exceptions::Exception) More...
 
static void setOutputs (int verboseLevel, int logLevel)
 Set the ostream for all items below "verboseLevel" to /dev/null or the log file (if the logLevel is set to 2) If verboseLevel is less than or equal to: More...
 
static void setStandardOutputs (int verboseLevel)
 Turn on/off std::cout, std::cerr, std::clog Redirect the standard outputs to /dev/null or log file depending on verboseLevel and logLevel: More...
 
static void setLog (int logLevel)
 Set up the log file stream. More...
 
static void closeLog ()
 Close the log file and free the memory. More...
 
static std::string getLogName ()
 Return the log file name. More...
 
static void setLogName (std::string aLogname)
 Set the log file name. More...
 
static void activateCout (bool isActive)
 Activate std::cout If isActive is false, redirects std::cout to /dev/null; if isActive is true, redirects it to std::cout. More...
 
static bool coutIsActive ()
 Return false if std::cout points to voidout; else true. More...
 
static void activateCerr (bool isActive)
 Activate std::cerr If isActive is false, redirects std::cerr to /dev/null; if isActive is true, redirects it to std::cerr. More...
 
static bool cerrIsActive ()
 Return false if std::cerr points to voidout; else true. More...
 
static void activateClog (bool isActive)
 Activate std::clog If isActive is false, redirects std::clog to /dev/null; if isActive is true, redirects it to std::clog. More...
 
static bool clogIsActive ()
 Return false if std::clog points to voidout; else true. More...
 
static std::ostream & nullOut ()
 Return ostream pointing to /dev/null (irrespective of verbose level) More...
 
static std::ostream & coutOut ()
 Return ostream pointing to standard output (irrespective of verb level) More...
 
static std::ostream & clogOut ()
 Return ostream pointing to standard log (irrespective of verbose level) More...
 
static std::ostream & cerrOut ()
 Return ostream pointing to standard error (irrespective of verb level) More...
 
static std::string levelStr (errorLevel level)
 Return the level of the error in plain english. More...
 
static void print (errorLevel level, std::string message)
 Prints a message with a certain severity level. More...
 
static void print (errorLevel level, std::string message, std::string func)
 Prints a message in a given function with a certain severity level. More...
 

Private Member Functions

 Pitch ()
 Constructor is called by any call to mout. Defines std::map output. More...
 

Static Private Member Functions

static Pitch * getInstance ()
 Ensures class is always instantiated whenever needed. More...
 
static void initialiseOutputs ()
 Setup outputs. More...
 
static void setException ()
 Set Exception. More...
 

Static Private Attributes

static std::map< errorLevel,
std::ostream * > 
output
 Links an ostream with each error level. More...
 
static std::ostream * voidout = NULL
 Dummy ostream to send stuff to /dev/null. More...
 
static std::ostream * stdout = NULL
 ostream that points to std::out More...
 
static std::ostream * stdlog = NULL
 ostream that points to std::log More...
 
static std::ostream * stderr = NULL
 ostream that points to std::err More...
 
static std::ofstream * logfile = NULL
 ostream that points to a log file More...
 
static const errorLevel default_error_level = Pitch::warning
 The default error level. More...
 
static const int default_log_level = 0
 The default log level. More...
 
static std::string logname = "emittance.log"
 The log file name. More...
 
static Pitch * instance = NULL
 Pointer to the singleton instance. More...
 

Detailed Description

Redirect output to std::out, std::cerr or file depending on severity.

Usage: Pitch::mout(Pitch::debug) << "Blah blah" << std::endl;

Pitch is used to redirect output at run time to some output file or standard outputs. Redirection is controlled by errorLevel: debug - debugging information. Deliver information related to debugging errors in the code; verbose developer level output info - run control information. Deliver information related to run information; aimed at users to give summary information about the run (idea is to give a constant, but limited, stream of data to info) warning - information to warn the user of suspected errors in running error - information to warn the user of certain errors in running fatal - final information to tell the user if the code is crashing

We also redirect output according to exceptionLevel recoverable - redirects to error nonRecoverable - redirects to fatal

Pitch is a singleton class - so initialisation is done whenever a function is called and the thing never destructs

Member Enumeration Documentation

Error level that determines where the output goes.

Constructor & Destructor Documentation

Pitch::Pitch ( )
private

Constructor is called by any call to mout. Defines std::map output.

Member Function Documentation

void Pitch::activateCerr ( bool  isActive)
static

Activate std::cerr If isActive is false, redirects std::cerr to /dev/null; if isActive is true, redirects it to std::cerr.

void Pitch::activateClog ( bool  isActive)
static

Activate std::clog If isActive is false, redirects std::clog to /dev/null; if isActive is true, redirects it to std::clog.

void Pitch::activateCout ( bool  isActive)
static

Activate std::cout If isActive is false, redirects std::cout to /dev/null; if isActive is true, redirects it to std::cout.

bool Pitch::cerrIsActive ( )
static

Return false if std::cerr points to voidout; else true.

std::ostream & Pitch::cerrOut ( )
static

Return ostream pointing to standard error (irrespective of verb level)

bool Pitch::clogIsActive ( )
static

Return false if std::clog points to voidout; else true.

std::ostream & Pitch::clogOut ( )
static

Return ostream pointing to standard log (irrespective of verbose level)

void Pitch::closeLog ( )
static

Close the log file and free the memory.

bool Pitch::coutIsActive ( )
static

Return false if std::cout points to voidout; else true.

std::ostream & Pitch::coutOut ( )
static

Return ostream pointing to standard output (irrespective of verb level)

Pitch * Pitch::getInstance ( )
staticprivate

Ensures class is always instantiated whenever needed.

Returns
Pointer to the singleton class instance
static std::string Pitch::getLogName ( )
inlinestatic

Return the log file name.

void Pitch::initialiseOutputs ( )
staticprivate

Setup outputs.

std::string Pitch::levelStr ( errorLevel  level)
static

Return the level of the error in plain english.

std::ostream & Pitch::mout ( )
static

Shorthand that returns output to Pitch::mout(Pitch::debug)

std::ostream & Pitch::mout ( errorLevel  level)
static

Returns a reference to the ostream corresponding to the errorLevel.

std::ostream & Pitch::mout ( Exceptions::exceptionLevel  level)
static

Returns a reference to the ostream corresponding to the exceptionLevel.

std::ostream & Pitch::nullOut ( )
static

Return ostream pointing to /dev/null (irrespective of verbose level)

void Pitch::print ( errorLevel  level,
std::string  message 
)
static

Prints a message with a certain severity level.

Parameters
levelLevel of severity of the message
messageMessage to print out along with the erreor
void Pitch::print ( errorLevel  level,
std::string  message,
std::string  func 
)
static

Prints a message in a given function with a certain severity level.

Parameters
levelLevel of severity of the message
messageMessage to print out along with the erreor
funcFunction in which the error was encountered
void Pitch::setAnOutput ( errorLevel  level,
std::ostream &  out 
)
static

Set the ostream for a given error level (Exceptions::Exception)

static void Pitch::setException ( )
staticprivate

Set Exception.

void Pitch::setLog ( int  logLevel)
static

Set up the log file stream.

  • if logLevel = 0 then Pitch::log will go to /dev/null
  • if logLevel = 1 file opened and Pitch::log will go there
  • if logLevel = 2 file opened, Pitch::log and any other streams not going to screen go there
static void Pitch::setLogName ( std::string  aLogname)
inlinestatic

Set the log file name.

void Pitch::setOutputs ( int  verboseLevel,
int  logLevel 
)
static

Set the ostream for all items below "verboseLevel" to /dev/null or the log file (if the logLevel is set to 2) If verboseLevel is less than or equal to:

  • Pitch::debug then mout(Pitch::debug) redirects to std::cout
  • Pitch::info then mout(Pitch::info) redirects to std::clog
  • Pitch::warning then mout(Pitch::warning) redirects to std::cerr
  • Pitch::error then mout(Pitch::error) redirects to std::cerr
  • Pitch::fatal then mout(Pitch::fatal) redirects to std::cerr Note that the redirection is independent of setStandardOutputs status
void Pitch::setStandardOutputs ( int  verboseLevel)
static

Turn on/off std::cout, std::cerr, std::clog Redirect the standard outputs to /dev/null or log file depending on verboseLevel and logLevel:

  • if verboseLevel > int(Pitch::debug), set std::cout to /dev/null or log file
  • if verboseLevel > int(Pitch::info), set std::clog to /dev/null or log file
  • if verboseLevel > int(Pitch::warning), set std::cerr to /dev/null or log file

Field Documentation

const Pitch::errorLevel Pitch::default_error_level = Pitch::warning
staticprivate

The default error level.

const int Pitch::default_log_level = 0
staticprivate

The default log level.

Pitch * Pitch::instance = NULL
staticprivate

Pointer to the singleton instance.

std::ofstream * Pitch::logfile = NULL
staticprivate

ostream that points to a log file

std::string Pitch::logname = "emittance.log"
staticprivate

The log file name.

std::map< Pitch::errorLevel, std::ostream * > Pitch::output
staticprivate

Links an ostream with each error level.

std::ostream * Pitch::stderr = NULL
staticprivate

ostream that points to std::err

std::ostream * Pitch::stdlog = NULL
staticprivate

ostream that points to std::log

std::ostream * Pitch::stdout = NULL
staticprivate

ostream that points to std::out

std::ostream * Pitch::voidout = NULL
staticprivate

Dummy ostream to send stuff to /dev/null.


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