2015-01-06 18:31:46 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2014 Statoil ASA.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2015-01-06 19:01:25 +01:00
|
|
|
#include <sstream>
|
|
|
|
|
#include <stdexcept>
|
2015-01-06 18:31:46 +01:00
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/OpmLog/OpmLog.hpp>
|
2015-01-06 21:18:55 +01:00
|
|
|
#include <opm/parser/eclipse/OpmLog/Logger.hpp>
|
2015-01-06 18:31:46 +01:00
|
|
|
|
|
|
|
|
namespace Opm {
|
|
|
|
|
|
|
|
|
|
|
2015-01-06 21:18:55 +01:00
|
|
|
std::shared_ptr<Logger> OpmLog::getLogger() {
|
|
|
|
|
if (!m_logger)
|
|
|
|
|
m_logger.reset( new Logger() );
|
2015-01-06 19:01:25 +01:00
|
|
|
|
2015-01-06 21:18:55 +01:00
|
|
|
return m_logger;
|
2015-01-06 19:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-06 18:31:46 +01:00
|
|
|
|
2015-01-06 21:18:55 +01:00
|
|
|
void OpmLog::addMessage(int64_t messageFlag , const std::string& message) {
|
2015-01-16 15:03:45 +01:00
|
|
|
if (m_logger)
|
|
|
|
|
m_logger->addMessage( messageFlag , message );
|
2015-01-06 19:31:52 +01:00
|
|
|
}
|
2015-01-06 19:01:25 +01:00
|
|
|
|
2015-01-09 14:15:25 +01:00
|
|
|
|
|
|
|
|
bool OpmLog::enabledMessageType( int64_t messageType ) {
|
2015-01-16 15:03:45 +01:00
|
|
|
if (m_logger)
|
|
|
|
|
return m_logger->enabledMessageType( messageType );
|
|
|
|
|
else
|
|
|
|
|
return Logger::enabledDefaultMessageType( messageType );
|
2015-01-09 14:15:25 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-16 15:03:45 +01:00
|
|
|
bool OpmLog::hasBackend(const std::string& name) {
|
|
|
|
|
if (m_logger)
|
|
|
|
|
return m_logger->hasBackend( name );
|
|
|
|
|
else
|
|
|
|
|
return false;
|
2015-01-09 14:15:25 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-06 19:01:25 +01:00
|
|
|
|
2015-01-20 18:13:17 +01:00
|
|
|
bool OpmLog::removeBackend(const std::string& name) {
|
|
|
|
|
if (m_logger)
|
|
|
|
|
return m_logger->removeBackend( name );
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-01-16 15:03:45 +01:00
|
|
|
void OpmLog::addMessageType( int64_t messageType , const std::string& prefix) {
|
2015-01-09 14:10:01 +01:00
|
|
|
auto logger = OpmLog::getLogger();
|
2015-01-16 15:03:45 +01:00
|
|
|
logger->addMessageType( messageType , prefix );
|
2015-01-09 14:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OpmLog::addBackend(const std::string& name , std::shared_ptr<LogBackend> backend) {
|
|
|
|
|
auto logger = OpmLog::getLogger();
|
|
|
|
|
return logger->addBackend( name , backend );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-01-06 19:01:25 +01:00
|
|
|
/******************************************************************/
|
|
|
|
|
|
2015-01-06 21:18:55 +01:00
|
|
|
std::shared_ptr<Logger> OpmLog::m_logger;
|
2015-01-06 18:31:46 +01:00
|
|
|
}
|