mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
new feature: DeferredLogger class
This commit is contained in:
91
opm/simulators/DeferredLogger.cpp
Normal file
91
opm/simulators/DeferredLogger.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2018 SINTEF Digital, Mathematics and Cybernetics.
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "opm/simulators/DeferredLogger.hpp"
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
void DeferredLogger::info(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Info, tag, message});
|
||||
}
|
||||
void DeferredLogger::warning(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Warning, tag, message});
|
||||
}
|
||||
void DeferredLogger::error(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Error, tag, message});
|
||||
}
|
||||
void DeferredLogger::problem(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Problem, tag, message});
|
||||
}
|
||||
void DeferredLogger::bug(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Bug, tag, message});
|
||||
}
|
||||
void DeferredLogger::debug(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Debug, tag, message});
|
||||
}
|
||||
void DeferredLogger::note(const std::string& tag, const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Note, tag, message});
|
||||
}
|
||||
|
||||
void DeferredLogger::info(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Info, "", message});
|
||||
}
|
||||
void DeferredLogger::warning(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Warning, "", message});
|
||||
}
|
||||
void DeferredLogger::error(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Error, "", message});
|
||||
}
|
||||
void DeferredLogger::problem(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Problem, "", message});
|
||||
}
|
||||
void DeferredLogger::bug(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Bug, "", message});
|
||||
}
|
||||
void DeferredLogger::debug(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Debug, "", message});
|
||||
}
|
||||
void DeferredLogger::note(const std::string& message)
|
||||
{
|
||||
messages_.push_back({Log::MessageType::Note, "", message});
|
||||
}
|
||||
|
||||
void DeferredLogger::logMessages()
|
||||
{
|
||||
for (const auto& m : messages_) {
|
||||
OpmLog::addTaggedMessage(m.flag, m.tag, m.text);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
65
opm/simulators/DeferredLogger.hpp
Normal file
65
opm/simulators/DeferredLogger.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2018 SINTEF Digital, Mathematics and Cybernetics.
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OPM_DEFERREDLOGGER_HEADER_INCLUDED
|
||||
#define OPM_DEFERREDLOGGER_HEADER_INCLUDED
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class DeferredLogger
|
||||
{
|
||||
public:
|
||||
void info(const std::string& tag, const std::string& message);
|
||||
void warning(const std::string& tag, const std::string& message);
|
||||
void error(const std::string& tag, const std::string& message);
|
||||
void problem(const std::string& tag, const std::string& message);
|
||||
void bug(const std::string& tag, const std::string& message);
|
||||
void debug(const std::string& tag, const std::string& message);
|
||||
void note(const std::string& tag, const std::string& message);
|
||||
|
||||
void info(const std::string& message);
|
||||
void warning(const std::string& message);
|
||||
void error(const std::string& message);
|
||||
void problem(const std::string& message);
|
||||
void bug(const std::string& message);
|
||||
void debug(const std::string& message);
|
||||
void note(const std::string& message);
|
||||
|
||||
void logMessages();
|
||||
|
||||
private:
|
||||
struct Message
|
||||
{
|
||||
int64_t flag;
|
||||
std::string tag;
|
||||
std::string text;
|
||||
};
|
||||
std::vector<Message> messages_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_DEFERREDLOGGER_HEADER_INCLUDED
|
||||
Reference in New Issue
Block a user