Class to carry out messages. More...
Public Member Functions | |
Messages () | |
Constructor for the Messages class. | |
~Messages () | |
Destructor for the Messages class. | |
void | addError (std::string r, std::string msg) |
Set an error condition in the application class without throwing an exception. | |
int | getErrorCount () |
Return the number of errors that have been encountered so far. | |
void | popError () |
Discard the last error message. | |
std::string | lastErrorMessage () |
Retrieve the last error message in a string. | |
void | getErrors (std::ostream &f) |
Prints all of the error messages to an ostream. | |
void | logErrors () |
Prints all of the error messages using writelog. | |
void | writelog (const std::string &msg) |
Write a message to the screen. | |
void | writelogendl () |
Write an end of line and flush output. | |
void | writelog (const char *pszmsg) |
Write a message to the screen. | |
void | logerror (const std::string &msg) |
Write an error message and quit. | |
int | getUserEnv () |
Returns an integer specifying the application environment. | |
void | setLogger (Logger *logwriter) |
Install a logger. | |
void | beginLogGroup (std::string title, int loglevel) |
Create a new group for log messages. | |
void | addLogEntry (std::string tag, std::string value) |
Add an entry to an HTML log file. | |
void | addLogEntry (std::string tag, doublereal value) |
Add an entry to an HTML log file. | |
void | addLogEntry (std::string tag, int value) |
Add an entry to an HTML log file. | |
void | addLogEntry (std::string msg) |
Add an entry to an HTML log file. | |
void | endLogGroup (std::string title) |
Close the current group of log messages. | |
void | write_logfile (std::string file) |
Write the HTML log file. | |
Protected Attributes | |
vector< string > | errorMessage |
Current list of error messages. | |
vector< string > | errorRoutine |
Current error Routine. | |
Logger * | logwriter |
Current pointer to the logwriter. | |
XML_Node * | xmllog |
Current pointer to the top of the XML_Node tree for the current HTML log. | |
XML_Node * | current |
Pointer to the last current position in the XML_Node tree for the current HTML log. | |
int | loglevel |
Current value of the loglevel. | |
vector< int > | loglevels |
Vector of loglevels for loggroups that are open. | |
vector< string > | loggroups |
Current vector of loggroups that are open. |
Class to carry out messages.
Definition at line 172 of file misc.cpp.
Messages | ( | ) | [inline] |
Constructor for the Messages class.
constructor for the Messages class which is a subclass of the Application class.
Definition at line 179 of file misc.cpp.
References Messages::current, Messages::loglevel, Messages::logwriter, and Messages::xmllog.
~Messages | ( | ) | [inline] |
Destructor for the Messages class.
Definition at line 191 of file misc.cpp.
References Messages::logwriter, Messages::write_logfile(), and Messages::xmllog.
void endLogGroup | ( | std::string | title | ) |
Close the current group of log messages.
This is typically called just before leaving a function or method, to close the group of messages that were output from this function. Subsequent messages written with addLogEntry() will appear at the next-higher level in the outline, unless beginLogGroup() is called first to create a new group.
title | Name of the log group. It defaults to the most recent log group created. |
Definition at line 1736 of file misc.cpp.
References AssertThrowMsg, Messages::current, Messages::loggroups, Messages::loglevel, Messages::loglevels, XML_Node::parent(), Messages::write_logfile(), and Messages::writelog().
int getUserEnv | ( | ) |
Returns an integer specifying the application environment.
Definition at line 1591 of file misc.cpp.
References Logger::env(), and Messages::logwriter.
void logerror | ( | const std::string & | msg | ) |
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.
msg | Error message to be written to cerr. |
Definition at line 1581 of file misc.cpp.
References Logger::error(), and Messages::logwriter.
void write_logfile | ( | std::string | file | ) |
Write the HTML log file.
Log entries are stored in memory in an XML tree until this function is called, which writes the tree to a file and clears the entries stored in memory. The output file will have the name specified in the 'file' argument. If this argument has no extension, the extension '.html' will be appended. Also, if the file already exists, an integer will be appended to the name so that no existing log file will be overwritten. WITH_HTML_LOGS must be defined.
file | Name of the file to be written |
Definition at line 1785 of file misc.cpp.
References Messages::current, Cantera::int2str(), XML_Node::root(), XML_Node::write(), Messages::writelog(), and Messages::xmllog.
Referenced by Messages::endLogGroup(), and Messages::~Messages().
void writelogendl | ( | ) |
Write an end of line and flush output.
Definition at line 1546 of file misc.cpp.
References Messages::logwriter, and Logger::writeendl().
Pointer to the last current position in the XML_Node tree for the current HTML log.
Definition at line 422 of file misc.cpp.
Referenced by Messages::addLogEntry(), Messages::beginLogGroup(), Messages::endLogGroup(), Messages::Messages(), and Messages::write_logfile().
vector<string> errorMessage [protected] |
Current list of error messages.
Definition at line 410 of file misc.cpp.
Referenced by Messages::addError(), Messages::getErrorCount(), Messages::getErrors(), Messages::lastErrorMessage(), Messages::logErrors(), and Messages::popError().
vector<string> errorRoutine [protected] |
Current error Routine.
Definition at line 413 of file misc.cpp.
Referenced by Messages::addError(), Messages::getErrors(), Messages::lastErrorMessage(), Messages::logErrors(), and Messages::popError().
vector<string> loggroups [protected] |
Current vector of loggroups that are open.
Definition at line 431 of file misc.cpp.
Referenced by Messages::beginLogGroup(), and Messages::endLogGroup().
int loglevel [protected] |
Current value of the loglevel.
Definition at line 425 of file misc.cpp.
Referenced by Messages::addLogEntry(), Messages::beginLogGroup(), Messages::endLogGroup(), and Messages::Messages().
vector<int> loglevels [protected] |
Vector of loglevels for loggroups that are open.
Definition at line 428 of file misc.cpp.
Referenced by Messages::beginLogGroup(), and Messages::endLogGroup().
Current pointer to the logwriter.
Definition at line 416 of file misc.cpp.
Referenced by Messages::getUserEnv(), Messages::logerror(), Messages::Messages(), Messages::setLogger(), Messages::writelog(), Messages::writelogendl(), and Messages::~Messages().
Current pointer to the top of the XML_Node tree for the current HTML log.
Definition at line 419 of file misc.cpp.
Referenced by Messages::beginLogGroup(), Messages::Messages(), Messages::write_logfile(), and Messages::~Messages().