OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::Logger Class Reference

Logger class used by OOFEM to print information during analysis. More...

#include <logger.h>

Public Types

enum  logLevelType {
  LOG_LEVEL_FORCED =-1, LOG_LEVEL_FATAL =0, LOG_LEVEL_ERROR =0, LOG_LEVEL_WARNING = 1,
  LOG_LEVEL_RELEVANT = 2, LOG_LEVEL_INFO = 3, LOG_LEVEL_ALL = 4, LOG_LEVEL_DEBUG = 4
}
 Type defining basic log levels. More...
 

Public Member Functions

 Logger (logLevelType level)
 
 ~Logger ()
 
void appendLogTo (const std::string &fname)
 Redirects log output to given file name (with path). More...
 
void appendErrorTo (const std::string &fname)
 Redirects error output to given file name (with path). More...
 
void appendLogTo (FILE *stream)
 Redirects log output to given stream. More...
 
void appendErrorTo (FILE *stream)
 Redirects error output to given stream. More...
 
void setComm (MPI_Comm comm)
 Parallell comm. More...
 
void writeLogMsg (logLevelType level, const char *format,...)
 Writes the normal log message. More...
 
void writeELogMsg (logLevelType level, const char *_func, const char *_file, int _line, const char *format,...)
 Writes extended log message with file and line info. More...
 
void flush ()
 Flushes the log stream. More...
 
void setLogLevel (logLevelType level)
 Sets log level to given one. Only log messages with level less or equal given threshold will be printed. More...
 
void setLogLevel (int level)
 Sets log level to given one. Only log messages with level less or equal given threshold will be printed. More...
 
void printStatistics ()
 Prints number of errors and warning logged. More...
 

Protected Member Functions

const char * giveLevelName (logLevelType l) const
 

Protected Attributes

FILE * logStream
 Stream used for logging. More...
 
FILE * errStream
 
bool closeFlag
 flag indicating whether to close mylogStream. More...
 
bool errCloseFlag
 
logLevelType logLevel
 Current log level, messages with higher level are not reported. More...
 
int numberOfWrn
 Counter of all warning and error messages. More...
 
int numberOfErr
 
MPI_Comm comm
 Parallell comm. More...
 

Detailed Description

Logger class used by OOFEM to print information during analysis.

Prints warnings and errors into a separate stream from normal output.

Definition at line 56 of file logger.h.

Member Enumeration Documentation

Type defining basic log levels.

Enumerator
LOG_LEVEL_FORCED 
LOG_LEVEL_FATAL 
LOG_LEVEL_ERROR 
LOG_LEVEL_WARNING 
LOG_LEVEL_RELEVANT 
LOG_LEVEL_INFO 
LOG_LEVEL_ALL 
LOG_LEVEL_DEBUG 

Definition at line 60 of file logger.h.

Constructor & Destructor Documentation

oofem::Logger::Logger ( logLevelType  level)

Definition at line 138 of file logger.C.

oofem::Logger::~Logger ( )

Definition at line 151 of file logger.C.

References closeFlag, errCloseFlag, errStream, and logStream.

Member Function Documentation

void oofem::Logger::appendErrorTo ( const std::string &  fname)

Redirects error output to given file name (with path).

Definition at line 181 of file logger.C.

References errCloseFlag, errStream, and OOFEM_WARNING.

void oofem::Logger::appendErrorTo ( FILE *  stream)

Redirects error output to given stream.

Definition at line 216 of file logger.C.

References errCloseFlag, errStream, and OOFEM_ERROR.

void oofem::Logger::appendLogTo ( const std::string &  fname)

Redirects log output to given file name (with path).

Definition at line 162 of file logger.C.

References closeFlag, logStream, and OOFEM_WARNING.

void oofem::Logger::appendLogTo ( FILE *  stream)

Redirects log output to given stream.

Definition at line 200 of file logger.C.

References closeFlag, logStream, and OOFEM_ERROR.

void oofem::Logger::flush ( )
inline

Flushes the log stream.

Definition at line 102 of file logger.h.

const char * oofem::Logger::giveLevelName ( logLevelType  l) const
protected

Definition at line 300 of file logger.C.

References LOG_LEVEL_ERROR, and LOG_LEVEL_WARNING.

Referenced by writeELogMsg().

void oofem::Logger::printStatistics ( )

Prints number of errors and warning logged.

Definition at line 332 of file logger.C.

References comm, logStream, numberOfErr, and numberOfWrn.

void oofem::Logger::setComm ( MPI_Comm  comm)

Parallell comm.

Definition at line 325 of file logger.C.

References comm.

void oofem::Logger::setLogLevel ( logLevelType  level)
inline

Sets log level to given one. Only log messages with level less or equal given threshold will be printed.

Definition at line 105 of file logger.h.

void oofem::Logger::setLogLevel ( int  level)

Sets log level to given one. Only log messages with level less or equal given threshold will be printed.

Definition at line 316 of file logger.C.

References LOG_LEVEL_DEBUG, LOG_LEVEL_FATAL, and logLevel.

void oofem::Logger::writeELogMsg ( logLevelType  level,
const char *  _func,
const char *  _file,
int  _line,
const char *  format,
  ... 
)
void oofem::Logger::writeLogMsg ( logLevelType  level,
const char *  format,
  ... 
)

Writes the normal log message.

Definition at line 234 of file logger.C.

References comm, errStream, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL, LOG_LEVEL_WARNING, logLevel, logStream, numberOfErr, and numberOfWrn.

Member Data Documentation

bool oofem::Logger::closeFlag
protected

flag indicating whether to close mylogStream.

Definition at line 72 of file logger.h.

Referenced by appendLogTo(), and ~Logger().

MPI_Comm oofem::Logger::comm
protected

Parallell comm.

Definition at line 79 of file logger.h.

Referenced by printStatistics(), setComm(), and writeLogMsg().

bool oofem::Logger::errCloseFlag
protected

Definition at line 72 of file logger.h.

Referenced by appendErrorTo(), and ~Logger().

FILE * oofem::Logger::errStream
protected

Definition at line 70 of file logger.h.

Referenced by appendErrorTo(), writeELogMsg(), writeLogMsg(), and ~Logger().

logLevelType oofem::Logger::logLevel
protected

Current log level, messages with higher level are not reported.

Definition at line 74 of file logger.h.

Referenced by setLogLevel(), writeELogMsg(), and writeLogMsg().

FILE* oofem::Logger::logStream
protected

Stream used for logging.

Definition at line 70 of file logger.h.

Referenced by appendLogTo(), printStatistics(), writeELogMsg(), writeLogMsg(), and ~Logger().

int oofem::Logger::numberOfErr
protected

Definition at line 76 of file logger.h.

Referenced by printStatistics(), writeELogMsg(), and writeLogMsg().

int oofem::Logger::numberOfWrn
protected

Counter of all warning and error messages.

Definition at line 76 of file logger.h.

Referenced by printStatistics(), writeELogMsg(), and writeLogMsg().


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:37 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011