OOFEM 3.0
Loading...
Searching...
No Matches
oofem::Logger Class Reference

#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).
void appendErrorTo (const std ::string &fname)
 Redirects error output to given file name (with path).
void appendLogTo (FILE *stream)
 Redirects log output to given stream.
void appendErrorTo (FILE *stream)
 Redirects error output to given stream.
void setComm (MPI_Comm comm)
 Parallell comm.
void writeLogMsg (logLevelType level, const char *format,...)
 Writes the normal log message.
void writeELogMsg (logLevelType level, const char *_func, const char *_file, int _line, const char *format,...)
 Writes extended log message with file and line info.
void flush ()
 Flushes the log stream.
void setLogLevel (logLevelType level)
 Sets log level to given one. Only log messages with level less or equal given threshold will be printed.
void setLogLevel (int level)
 Sets log level to given one. Only log messages with level less or equal given threshold will be printed.
void incrementErrorCounter ()
 Increment error count by one.
void printStatistics ()
 Prints number of errors and warning logged.
void getNumberOfWarningsAndErrors (int &nwrns, int &nerrs)
 Returns local (mpi-process) statistics.

Protected Member Functions

const char * giveLevelName (logLevelType l) const

Protected Attributes

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

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 57 of file logger.h.

Member Enumeration Documentation

◆ logLevelType

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 61 of file logger.h.

Constructor & Destructor Documentation

◆ Logger()

oofem::Logger::Logger ( logLevelType level)

Definition at line 52 of file logger.C.

References closeFlag, comm, errCloseFlag, errStream, logLevel, logStream, numberOfErr, and numberOfWrn.

◆ ~Logger()

oofem::Logger::~Logger ( )

Definition at line 65 of file logger.C.

References closeFlag, errCloseFlag, errStream, and logStream.

Member Function Documentation

◆ appendErrorTo() [1/2]

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

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

Definition at line 95 of file logger.C.

References errCloseFlag, errStream, and OOFEM_WARNING.

◆ appendErrorTo() [2/2]

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

Redirects error output to given stream.

Definition at line 130 of file logger.C.

References errCloseFlag, errStream, and OOFEM_ERROR.

◆ appendLogTo() [1/2]

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

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

Definition at line 76 of file logger.C.

References closeFlag, logStream, and OOFEM_WARNING.

◆ appendLogTo() [2/2]

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

Redirects log output to given stream.

Definition at line 114 of file logger.C.

References closeFlag, logStream, and OOFEM_ERROR.

◆ flush()

void oofem::Logger::flush ( )
inline

Flushes the log stream.

Definition at line 111 of file logger.h.

References errStream, and logStream.

◆ getNumberOfWarningsAndErrors()

void oofem::Logger::getNumberOfWarningsAndErrors ( int & nwrns,
int & nerrs )
inline

Returns local (mpi-process) statistics.

Definition at line 122 of file logger.h.

References numberOfErr, and numberOfWrn.

◆ giveLevelName()

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

Definition at line 223 of file logger.C.

References LOG_LEVEL_ERROR, and LOG_LEVEL_WARNING.

Referenced by writeELogMsg().

◆ incrementErrorCounter()

void oofem::Logger::incrementErrorCounter ( )
inline

Increment error count by one.

Definition at line 118 of file logger.h.

References numberOfErr.

◆ printStatistics()

void oofem::Logger::printStatistics ( )

Prints number of errors and warning logged.

Definition at line 255 of file logger.C.

References comm, logStream, numberOfErr, and numberOfWrn.

◆ setComm()

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

Parallell comm.

Definition at line 248 of file logger.C.

References comm.

◆ setLogLevel() [1/2]

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 239 of file logger.C.

References LOG_LEVEL_DEBUG, LOG_LEVEL_FATAL, and logLevel.

◆ setLogLevel() [2/2]

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 114 of file logger.h.

References logLevel.

◆ writeELogMsg()

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

Writes extended log message with file and line info.

Definition at line 179 of file logger.C.

References errStream, giveLevelName(), LOG_ERR_HEADER, LOG_ERR_TAIL, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL, LOG_LEVEL_WARNING, logLevel, logStream, numberOfErr, numberOfWrn, and oofem::print_stacktrace().

◆ writeLogMsg()

void oofem::Logger::writeLogMsg ( logLevelType level,
const char * format,
... )

Writes the normal log message.

Definition at line 148 of file logger.C.

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

Member Data Documentation

◆ closeFlag

bool oofem::Logger::closeFlag
protected

flag indicating whether to close mylogStream.

Definition at line 73 of file logger.h.

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

◆ comm

MPI_Comm oofem::Logger::comm
protected

Parallell comm.

Definition at line 80 of file logger.h.

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

◆ errCloseFlag

bool oofem::Logger::errCloseFlag
protected

Definition at line 73 of file logger.h.

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

◆ errStream

FILE * oofem::Logger::errStream
protected

Definition at line 71 of file logger.h.

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

◆ logLevel

logLevelType oofem::Logger::logLevel
protected

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

Definition at line 75 of file logger.h.

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

◆ logStream

FILE* oofem::Logger::logStream
protected

Stream used for logging.

Definition at line 71 of file logger.h.

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

◆ numberOfErr

int oofem::Logger::numberOfErr
protected

◆ numberOfWrn

int oofem::Logger::numberOfWrn
protected

Counter of all warning and error messages.

Definition at line 77 of file logger.h.

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


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011