1 // Copyright (C) 2006-2008 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
20 #include "LogRecord.hxx"
25 #include "YacsTrace.hxx"
27 using namespace YACS::ENGINE;
29 Logger::Logger(const std::string& name):_name(name)
38 const std::string& Logger::getName()
43 void Logger::log(int level,const std::string& message,const char* filename,int line)
45 LogRecord* record=makeRecord(getName(),level,message,filename,line);
49 void Logger::error(const std::string& message,const char* filename,int line)
51 log(LogRecord::ERROR,message,filename,line);
54 void Logger::fatal(const std::string& message,const char* filename,int line)
56 log(LogRecord::FATAL,message,filename,line);
59 void Logger::warning(const std::string& message,const char* filename,int line)
61 log(LogRecord::WARNING,message,filename,line);
64 LogRecord* Logger::makeRecord(const std::string& name,int level,const std::string& message,const char* filename,int line)
66 return new LogRecord(name,level,message,filename,line);
69 void Logger::handle(LogRecord* record)
71 _records.push_back(record);
76 std::vector<LogRecord*>::iterator it;
77 for( it = _records.begin(); it != _records.end(); it++)
84 std::string Logger::getStr()
86 std::vector<LogRecord*>::iterator it;
88 for( it = _records.begin(); it != _records.end(); it++)
90 msg=msg + (*it)->getStr() + '\n';
95 bool Logger::isEmpty()
97 return _records.size() == 0;
100 bool Logger::hasErrors()
103 std::vector<LogRecord*>::iterator it;
104 for( it = _records.begin(); it != _records.end(); it++)
106 if((*it)->_level > LogRecord::WARNING)