Version: 8.3.0
YACS::ENGINE::Logger Class Reference

Class for logging error messages. More...

#include <Logger.hxx>

Collaboration diagram for YACS::ENGINE::Logger:

Public Member Functions

 Logger (const std::string &name)
 
virtual ~Logger ()
 
virtual const std::string & getName ()
 
virtual void log (int level, const std::string &message, const char *filename, int line)
 
virtual void error (const std::string &message, const char *filename, int line)
 
virtual void fatal (const std::string &message, const char *filename, int line)
 
virtual void warning (const std::string &message, const char *filename, int line)
 
virtual LogRecordmakeRecord (const std::string &name, int level, const std::string &message, const char *filename, int line)
 
virtual void handle (LogRecord *record)
 
virtual void reset ()
 
virtual std::string getStr ()
 
virtual bool isEmpty ()
 
virtual bool hasErrors ()
 

Protected Attributes

std::string _name
 
std::vector< LogRecord * > _records
 

Detailed Description

Class for logging error messages.

Definition at line 37 of file Logger.hxx.

Constructor & Destructor Documentation

Logger::Logger ( const std::string &  name)

Definition at line 30 of file Logger.cxx.

30  :_name(name)
31 {
32 }
Logger::~Logger ( )
virtual

Definition at line 34 of file Logger.cxx.

References reset().

35 {
36  reset();
37 }

Member Function Documentation

void Logger::error ( const std::string &  message,
const char *  filename,
int  line 
)
virtual

Definition at line 50 of file Logger.cxx.

References YACS::ENGINE::LogRecord::ERROR, and log().

Referenced by YACS::parser::logError().

51 {
52  log(LogRecord::ERROR,message,filename,line);
53 }
void Logger::fatal ( const std::string &  message,
const char *  filename,
int  line 
)
virtual

Definition at line 55 of file Logger.cxx.

References YACS::ENGINE::LogRecord::FATAL, and log().

Referenced by YACS::YACSLoader::load().

56 {
57  log(LogRecord::FATAL,message,filename,line);
58 }
const std::string & Logger::getName ( )
virtual

Definition at line 39 of file Logger.cxx.

References _name.

Referenced by log().

40 {
41  return _name;
42 }
std::string Logger::getStr ( )
virtual

Definition at line 85 of file Logger.cxx.

References _records.

Referenced by YACS::ENGINE::ProcCataLoader::loadCata(), YACS::HMI::GenericGui::loadSchema(), main(), YACS::HMI::GenericGui::onImportSchema(), YACS::HMI::GenericGui::onImportSupervSchema(), YACS::HMI::GenericGui::onLoadAndRunSchema(), YACS::HMI::EditionProc::synchronize(), and YACS::HMI::BatchJobsListDialog::userOK().

86 {
87  std::vector<LogRecord*>::iterator it;
88  std::string msg;
89  for( it = _records.begin(); it != _records.end(); it++)
90  {
91  msg=msg + (*it)->getStr() + '\n';
92  }
93  return msg;
94 }
void Logger::handle ( LogRecord record)
virtual

Definition at line 70 of file Logger.cxx.

References _records.

Referenced by log().

71 {
72  _records.push_back(record);
73 }
bool Logger::hasErrors ( )
virtual

Definition at line 101 of file Logger.cxx.

References _records, PMMLBasicsTestLauncher::ret, and YACS::ENGINE::LogRecord::WARNING.

Referenced by main().

102 {
103  bool ret=false;
104  std::vector<LogRecord*>::iterator it;
105  for( it = _records.begin(); it != _records.end(); it++)
106  {
107  if((*it)->_level > LogRecord::WARNING)
108  {
109  ret=true;
110  break;
111  }
112  }
113  return ret;
114 }
void Logger::log ( int  level,
const std::string &  message,
const char *  filename,
int  line 
)
virtual

Definition at line 44 of file Logger.cxx.

References getName(), handle(), and makeRecord().

Referenced by error(), fatal(), and warning().

45 {
46  LogRecord* record=makeRecord(getName(),level,message,filename,line);
47  handle(record);
48 }
LogRecord * Logger::makeRecord ( const std::string &  name,
int  level,
const std::string &  message,
const char *  filename,
int  line 
)
virtual

Definition at line 65 of file Logger.cxx.

Referenced by log().

66 {
67  return new LogRecord(name,level,message,filename,line);
68 }
void Logger::reset ( )
virtual

Definition at line 75 of file Logger.cxx.

References _records.

Referenced by gui.graph.grid::findPath(), and ~Logger().

76 {
77  std::vector<LogRecord*>::iterator it;
78  for( it = _records.begin(); it != _records.end(); it++)
79  {
80  delete (*it);
81  }
82  _records.clear();
83 }
void Logger::warning ( const std::string &  message,
const char *  filename,
int  line 
)
virtual

Definition at line 60 of file Logger.cxx.

References log(), and YACS::ENGINE::LogRecord::WARNING.

61 {
62  log(LogRecord::WARNING,message,filename,line);
63 }

Member Data Documentation

std::string YACS::ENGINE::Logger::_name
protected

Definition at line 54 of file Logger.hxx.

Referenced by getName().

std::vector<LogRecord*> YACS::ENGINE::Logger::_records
protected

Definition at line 55 of file Logger.hxx.

Referenced by getStr(), handle(), hasErrors(), isEmpty(), and reset().


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