Logger Class Reference
[Writing messages to the screen]

Base class for 'loggers' that write text messages to log files. More...

#include <logger.h>

List of all members.

Public Member Functions

 Logger ()
 Constructor - empty.
virtual ~Logger ()
 Destructor - empty.
virtual void write (const std::string &msg)
 Write a log message.
virtual void writeendl ()
 Write an end of line character and flush output.
virtual void error (const std::string &msg)
 Write an error message and quit.
virtual int env ()
 Return an integer specifying the application environment.

Detailed Description

Base class for 'loggers' that write text messages to log files.

This class is used to direct log messages to application- or environment-specific output. The default is to simply print the messages to the standard output stream or standard error stream, but classes may be derived from Logger that implement other output options. This is important when Cantera is used in applications that do not display the standard output, such as MATLAB. The Cantera MATLAB interface derives a class from Logger that implements these methods with MATLAB-specific procedures, insuring that the messages will be passed through to the user. It would also be possible to derive a class that displayed the messages in a pop-up window, or redirected them to a file, etc.

To install a logger, call function setLogger (global.h / misc.cpp).

See the files Cantera/python/src/pylogger.h and Cantera/matlab/cantera/private/mllogger.h for examples of deriving logger classes.

Definition at line 42 of file logger.h.


Constructor & Destructor Documentation

Logger (  )  [inline]

Constructor - empty.

Definition at line 46 of file logger.h.

virtual ~Logger (  )  [inline, virtual]

Destructor - empty.

Definition at line 49 of file logger.h.


Member Function Documentation

virtual int env (  )  [inline, virtual]

Return an integer specifying the application environment.

Definition at line 92 of file logger.h.

Referenced by Messages::getUserEnv().

virtual void error ( const std::string &  msg  )  [inline, virtual]

Write an error message and quit.

The default behavior is to write to the standard eror stream, and then call exit(). Note that no end-of-line character is appended to the message, and so if one is desired it must be included in the string. Note that this default behavior will terminate the application Cantera is invoked from (MATLAB, Excel, etc.) If this is not desired, then derive a class and reimplement this method.

Parameters:
msg Error message to be written to cerr.

Definition at line 86 of file logger.h.

Referenced by Messages::logerror(), and Cantera::setLogger().

virtual void write ( const std::string &  msg  )  [inline, virtual]

Write a log message.

The default behavior is to write to the standard output. Note that no end-of-line character is appended to the message, and so if one is desired it must be included in the string.

Parameters:
msg String message to be written to cout

Definition at line 60 of file logger.h.

Referenced by Messages::writelog().

virtual void writeendl (  )  [inline, virtual]

Write an end of line character and flush output.

Some systems treat endl and
differently. The endl statement causes a flushing of stdout to the screen.

Definition at line 69 of file logger.h.

Referenced by Messages::writelogendl().


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.3