Cantera  3.0.0
Loading...
Searching...
No Matches

Logging and generation of diagnostic output. More...

Collaboration diagram for Logging:

Detailed Description

Logging and generation of diagnostic output.

Writing diagnostic information to the screen or to a file. It is often useful to be able to write diagnostic messages to the screen or to a file. Cantera defines a set of procedures for this purpose designed to write text messages to the screen to document the progress of a complex calculation, such as a flame simulation.

Classes

class  ExternalLogger
 Logger that delegates to an external source via a callback to produce log output. More...
 
class  Logger
 Base class for 'loggers' that write text messages to log files. More...
 
class  NoExitLogger
 Logger that doesn't exit when an error is thrown. More...
 

Functions

void writelog (const string &msg)
 Write a message to the screen.
 
void warnlog (const string &warning, const string &msg)
 Write a warning message to the screen.
 
void setLogger (Logger *logwriter)
 Install a logger.
 
void writelog_direct (const string &msg)
 Write a message to the screen.
 
void debuglog (const string &msg, int loglevel)
 Write a message to the log only if loglevel > 0.
 
template<typename... Args>
void writelog (const string &fmt, const Args &... args)
 Write a formatted message to the screen.
 
template<typename... Args>
void writelogf (const char *fmt, const Args &... args)
 Write a formatted message to the screen.
 
void writelogendl ()
 Write an end of line character to the screen and flush output.
 
void writeline (char repeat, size_t count, bool endl_after, bool endl_before)
 
void setLogger (Logger *logwriter)
 Install a logger.
 

Function Documentation

◆ writelog() [1/2]

void writelog ( const string &  msg)

Write a message to the screen.

The string may be of any length, and may contain end-of-line characters. This method is used throughout Cantera to write log messages. It can also be called by user programs. The advantage of using writelog over writing directly to the standard output is that messages written with writelog will display correctly even when Cantera is used from MATLAB or other application that do not have a standard output stream.

Parameters
msgc++ string to be written to the screen

Definition at line 69 of file application.cpp.

◆ warnlog()

void warnlog ( const string &  warning,
const string &  msg 
)

Write a warning message to the screen.

Parameters
warningString specifying type of warning; see Logger::warn()
msgString to be written to the screen

Definition at line 79 of file application.cpp.

◆ setLogger() [1/2]

void setLogger ( Logger logwriter)

Install a logger.

Called by the language interfaces to install an appropriate logger. The logger is used for the writelog() function

Parameters
logwriterPointer to a logger object
See also
Logger.

Definition at line 64 of file application.cpp.

◆ writelog_direct()

void writelog_direct ( const string &  msg)

Write a message to the screen.

The string may be of any length, and may contain end-of-line characters. This method is used throughout Cantera to write log messages. It can also be called by user programs. The advantage of using writelog over writing directly to the standard output is that messages written with writelog will display correctly even when Cantera is used from MATLAB or other application that do not have a standard output stream.

Parameters
msgc++ string to be written to the screen

Definition at line 36 of file global.cpp.

◆ debuglog()

void debuglog ( const string &  msg,
int  loglevel 
)
inline

Write a message to the log only if loglevel > 0.

Definition at line 158 of file global.h.

◆ writelog() [2/2]

template<typename... Args>
void writelog ( const string &  fmt,
const Args &...  args 
)

Write a formatted message to the screen.

This function passes its arguments to the fmt library 'format' function to generate a formatted string from a Python-style (curly braces) format string. This method is used throughout Cantera to write log messages. It can also be called by user programs. The advantage of using writelog over writing directly to the standard output is that messages written with writelog will display correctly even when Cantera is used from MATLAB or other application that do not have a standard output stream.

Definition at line 175 of file global.h.

◆ writelogf()

template<typename... Args>
void writelogf ( const char *  fmt,
const Args &...  args 
)

Write a formatted message to the screen.

Using the printf formatting of C, write a message to the screen with variable values.

Here, we format an internal string with the correct values and then feed it into writelog().

Parameters
fmtc format string for the following arguments
argsarguments used to interpolate the format string

Definition at line 195 of file global.h.

◆ writelogendl()

void writelogendl ( )

Write an end of line character to the screen and flush output.

Definition at line 41 of file global.cpp.

◆ writeline()

void writeline ( char  repeat,
size_t  count,
bool  endl_after,
bool  endl_before 
)

Definition at line 46 of file global.cpp.

◆ setLogger() [2/2]

void setLogger ( Logger logwriter)

Install a logger.

Called by the language interfaces to install an appropriate logger. The logger is used for the writelog() function

Parameters
logwriterPointer to a logger object
See also
Logger.

Definition at line 27 of file global.cpp.