1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "LogRecord.hxx"
26 #include "YacsTrace.hxx"
28 using namespace YACS::ENGINE;
30 Logger::Logger(const std::string& name):_name(name)
39 const std::string& Logger::getName()
44 void Logger::log(int level,const std::string& message,const char* filename,int line)
46 LogRecord* record=makeRecord(getName(),level,message,filename,line);
50 void Logger::error(const std::string& message,const char* filename,int line)
52 log(LogRecord::ERROR,message,filename,line);
55 void Logger::fatal(const std::string& message,const char* filename,int line)
57 log(LogRecord::FATAL,message,filename,line);
60 void Logger::warning(const std::string& message,const char* filename,int line)
62 log(LogRecord::WARNING,message,filename,line);
65 LogRecord* Logger::makeRecord(const std::string& name,int level,const std::string& message,const char* filename,int line)
67 return new LogRecord(name,level,message,filename,line);
70 void Logger::handle(LogRecord* record)
72 _records.push_back(record);
77 std::vector<LogRecord*>::iterator it;
78 for( it = _records.begin(); it != _records.end(); it++)
85 std::string Logger::getStr()
87 std::vector<LogRecord*>::iterator it;
89 for( it = _records.begin(); it != _records.end(); it++)
91 msg=msg + (*it)->getStr() + '\n';
96 bool Logger::isEmpty()
98 return _records.size() == 0;
101 bool Logger::hasErrors()
104 std::vector<LogRecord*>::iterator it;
105 for( it = _records.begin(); it != _records.end(); it++)
107 if((*it)->_level > LogRecord::WARNING)