Version: 9.15.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::Logger ( const std::string &  name)

Definition at line 30 of file Logger.cxx.

30  :_name(name)
31 {
32 }
std::string _name
Definition: Logger.hxx:54

◆ ~Logger()

Logger::~Logger ( )
virtual

Definition at line 34 of file Logger.cxx.

35 {
36  reset();
37 }
virtual void reset()
Definition: Logger.cxx:75

References reset().

Member Function Documentation

◆ error()

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

Definition at line 50 of file Logger.cxx.

51 {
52  log(LogRecord::ERROR,message,filename,line);
53 }
static const LogLevel ERROR
Definition: LogRecord.hxx:37
virtual void log(int level, const std::string &message, const char *filename, int line)
Definition: Logger.cxx:44

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

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

◆ fatal()

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

Definition at line 55 of file Logger.cxx.

56 {
57  log(LogRecord::FATAL,message,filename,line);
58 }
static const LogLevel FATAL
Definition: LogRecord.hxx:36

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

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

◆ getName()

const std::string & Logger::getName ( )
virtual

Definition at line 39 of file Logger.cxx.

40 {
41  return _name;
42 }

References _name.

Referenced by log().

◆ getStr()

std::string Logger::getStr ( )
virtual

Definition at line 85 of file Logger.cxx.

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 }
std::vector< LogRecord * > _records
Definition: Logger.hxx:55

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().

◆ handle()

void Logger::handle ( LogRecord record)
virtual

Definition at line 70 of file Logger.cxx.

71 {
72  _records.push_back(record);
73 }

References _records.

Referenced by log().

◆ hasErrors()

bool Logger::hasErrors ( )
virtual

Definition at line 101 of file Logger.cxx.

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 }
static const LogLevel WARNING
Definition: LogRecord.hxx:38

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

Referenced by main().

◆ isEmpty()

◆ log()

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

Definition at line 44 of file Logger.cxx.

45 {
46  LogRecord* record=makeRecord(getName(),level,message,filename,line);
47  handle(record);
48 }
Class for logging record.
Definition: LogRecord.hxx:33
virtual void handle(LogRecord *record)
Definition: Logger.cxx:70
virtual const std::string & getName()
Definition: Logger.cxx:39
virtual LogRecord * makeRecord(const std::string &name, int level, const std::string &message, const char *filename, int line)
Definition: Logger.cxx:65

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

Referenced by error(), fatal(), gui.Appli.Browser::view_log(), and warning().

◆ makeRecord()

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.

66 {
67  return new LogRecord(name,level,message,filename,line);
68 }

Referenced by log().

◆ reset()

void Logger::reset ( )
virtual

Definition at line 75 of file Logger.cxx.

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 }

References _records.

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

◆ warning()

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

Definition at line 60 of file Logger.cxx.

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

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

Member Data Documentation

◆ _name

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

Definition at line 54 of file Logger.hxx.

Referenced by getName().

◆ _records

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: